Algorithms Forever ...

Friday, June 22, 2012

Range Search

›
Given an sorted array of integers, perform binary search to find the index of the range in which the number lies. A range is specified by ...

Fixed Point

›
Given an array of N distinct integers sorted in ascending order, write a function that returns a Fixed Point in the array, if there is any...

Subarray with Specific Sum

›
Given an unsorted array of nonnegative integers, find a continuous subarray which adds to a given number. Examples: Input: arr[] = {1...
2 comments:
Sunday, June 10, 2012

Constant Boundary Separation

›
Given an integer k and an sorted array A (can consist of both positive and negative numbers), output 2 integers from A such that a-b=k in ...
Saturday, January 7, 2012

Circular Swap

›
Given three numbers a, b and c. Write a program to swap them circularly (as per following example) using only one single statement in any ...
Friday, December 30, 2011

Integer Binary Roots

›
An integer obtained by reversing the bits of a given integer A is denoted as bit-rev(A). For example, bit-rev(25) = 19, because the binar...
Sunday, December 25, 2011

Random Pointer Reversal

›
Consider a Linked List with each Node, in addition to having a 'next' pointer also has a 'random' pointer. The 'random...
Sunday, December 4, 2011

Occurrence Count

›
Given a sorted array input[] of size N with possible duplicate integer elements. Devise an algorithm to find out the count of occurrences ...
Tuesday, November 8, 2011

Largest 100

›
There is a big file containing 10^8 integers, one per line. Devise an algorithm to find the largest 100 integers among them. Remember you ...
Monday, November 7, 2011

Bitonic array

›
Given an array of N distinct integers with the property that there exists an index K (0 <= K <= N-1) such that input[0], ..., input...

Largest Non Consecutive Subsequence

›
Given a sequence of N integers, devise an algorithm to find a sub-sequence S[] for which sum of its elements is maximum and such that S c...
3 comments:
Thursday, November 3, 2011

Adjacent removal

›
Given a string. Write an algorithm to remove adjacent characters if they are same. Ex. Input = abccbcba remove cc => abbcba remove bb =...

Lonely element

›
Given an array of integers with size 2N+1 such that N elements appear twice in arbitrary positions and 1 element appears only once. Devis...
Tuesday, November 1, 2011

Check range

›
Write a function that takes an int array of size M, and returns (true/false) if the array consists of the numbers only within the range [...

Find repeated element

›
Given an array of size N which contains all the numbers from 1 to N-1. Find the number which is repeated in O(N) time. How do you proceed ...
›
Home
View web version

About Me

My photo
Tranquil
Always Endeavor to Awaken the Divine Light of Knowledge, Wisdom and Love ...
View my complete profile
Powered by Blogger.