You are given 1 million unique numbers. - How would you sort them? - What if i dont have enough main memory(RAM) to hold the data in memory - What if the data is 7 digits long(min:0000000 to max:9999999)
Given a stack S, write a C program to sort the stack (in the ascending
order).
We are not allowed to make any assumptions about how the stack is implemented.
The only functions to be used are:
Push
Pop
Top
IsEmpty
IsFull
Find 2 elements in set equal to a given value in O(n ln n) time
[2007-02-26 23:42:19]   
Describe a O(n ln n) - time algorithm that, given a set S of n real numbers and another real number x, determines whether or not there exists two elements in S whose sum is exactly x.
#
Say we have a data structure as follows:
enum {RED,BLUE,GREEN};
struct Ball
{
/*...*/
int color;
};
int ColorOfBall(Ball b)
{
return b.color;
}
Ball arr[SIZE];
The array arr consists of balls of with one of the three colours
(Red,Green,Blue). Now we need to sort the array in such a way that all
the Red coloured balls come first, followed by blue and then green.
The restriction is that call to function ColorOfBall is a very costly
operation. You have to use it as less as possible. (In other words we
would be looking for the solution with least number of calls to the
function ColorOfBall.)
Array - Find a number which is addition of 2 other numbers
[2007-08-18 01:22:40]   
Given an array of n numbers and given a number x, find 2 integers in that array which will add up to that given number.
Should be done in time worst case O(n lg n).