-
Consider an array of integers, both positive and negative. You have to
find out the maximum sum possible by adding 'n' consecutive integers in
the array, n <= [ARRAY_SIZE]. Also give where in the array this sequence
of n integers starts.
-
Given two sorted linked lists, L1 and L2, write a C program to compute
L1 /\ L2 (L1 intersection L2).
-
Propose a data structure that supports the stack push and pop operations
and a third operation find_min, which returns the smallest element in
the data structure, all in O(1) worst case time.
-
Given an array of integers (possibly some of the elements negative),
write a C program to find out the *maximum product* possible by adding
'n' consecutive integers in the array, n <= ARRAY_SIZE.
Also give where in the array this sequence of n integers starts.
-
A man has two cubes on his desk. Every day he arranges both cubes so that
the front faces show the current day of the month. What numbers are on the
faces of the cubes to allow this?
-
Given 6 match sticks of equal length. You are asked to form 4
equilateral triangles with these sticks. Obviously, you are not allowed
to break, split or bend the sticks.
-
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.)