##
Count number of occurrences (or frequency) in a sorted array
May 3, 2011

Given a sorted array arr[] and a number x, write a function that counts the occurrences of x in arr[]. Expected time complexity is O(Logn)

May 3, 2011

Given a sorted array arr[] and a number x, write a function that counts the occurrences of x in arr[]. Expected time complexity is O(Logn)

March 12, 2011

Given an integer array of length N (an arbitrarily large number). How to count number of set bits in the array?

September 12, 2010

Method 1 (Using Nested Loops) We can calculate power by using repeated addition.

February 15, 2010

Write a C function to return minimum and maximum in an array. You program should make minimum number of comparisons.

February 11, 2010

Question: Write a C function to find if a given integer x appears more than n/2 times in a sorted array of n integers.

January 5, 2010

Inversion Count for an array indicates – how far (or close) the array is from being sorted. If array is already sorted then inversion count is 0. If array is sorted in reverse order that inversion count is the maximum.

September 28, 2009

Question: There are 2 sorted arrays A and B of size n each. Write an algorithm to find the median of the array obtained after merging the above 2 arrays(i.e. array of length 2n). The complexity should be O(log(n))

March 22, 2009

Below solution divides the problem into subproblems of size y/2 and call the subproblems recursively.