Largest Sum Contiguous Subarray Write an efficient C program to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum. Kadane’s Algorithm: Initialize: max_so_far = 0 max_ending_here = 0 Loop for each element of the array (a) max_ending_here = max_ending_here + a[i] (b) if(max_ending_here < 0) max_ending_here =

# Authorrakesh

## Search, insert and delete in an unsorted array

Search, insert and delete in an unsorted array In this post search, insert and delete operation in an unsorted array is discussed. Search Operation In an unsorted array, the search operation can be performed by linear traversal from the first element to the last element. // C program to implement linear search in // unsorted

## C program to simulate Nondeterministic Finite Automata (NFA)

C program to simulate Nondeterministic Finite Automata (NFA) Background An NFA is typically described using a directed graph. Each edge and vertex is labeled either 0 or 1 representing possible transitions. Vertices represent the states of the NFA. Those labeled 0 are non accepting states, and those labeled 1 are accepting states. It takes an

## Commonly Asked C Programming Interview Questions | Set 1

What is the difference between declaration and definition of a variable/function Ans: Declaration of a variable/function simply declares that the variable/function exists somewhere in the program but the memory is not allocated for them. But the declaration of a variable/function serves an important role. And that is the type of the variable/function. Therefore, when a

## 10 Most asked Questions from Java Programmers

10 Most asked Questions from Java Programmers Hope you liked my previous post “Top 25 Interview Questions”. Here comes the next 10. 1) Design discussion on elevator. Hint: Ask questions related to elevator functionality; come up with a High Level design and Low level design. Be prepared for scheduling questions related to elevator. 2) “n”

## How to begin with Competitive Programming?

How to begin with Competitive Programming? At the very beginning to competitive programming, barely anyone knows the coding style to be followed. Below is an example to help understand that style. Let us consider below problem statement as an example. Problem Statement: Linear Search: Given an integer array and an element x, find if element

## Commonly asked Interview Questions for Front End Developers

Commonly asked Interview Questions for Front End Developers 1) CSS, JS best practices? Strict mode, etc. 2) Mention some IE CSS issues faced by developers. 3) How to defer an element’s event handler if it depends on an external script that takes some time to load? 4) Optimal strategy for winning a game where let’s

## A Step by Step Guide for Placement Preparation | Set 2

A Step by Step Guide for Placement Preparation | Set 2 Prerequisite – Set -1 Tech giants look for the candidates who generally are excellent in algorithm designing and coding. You can surely not skip data structures and algorithms if you are looking to prepare for companies like Google, Facebook, Microsoft, Amazon, etc. Revise the

## Find the Number Occurring Odd Number of Times

Find the Number Occurring Odd Number of Times Given an array of positive integers. All numbers occur even number of times except one number which occurs odd number of times. Find the number in O(n) time & constant space. Example: I/P = [1, 2, 3, 2, 3, 1, 3] O/P = 3 A Simple Solution

## Majority Element

Majority Element Majority Element: A majority element in an array A[] of size n is an element that appears more than n/2 times (and hence there is at most one such element). Write a function which takes an array and emits the majority element (if it exists), otherwise prints NONE as follows: I/P : 3