Tuesday, September 15, 2009
Cut it now
1 such that no two rectangles are the same size. A solution with nine rectangles
is known.
Permutations
six distances between pairs of points take on only two different values?
Many crypto doorknob locks use doors with five buttons numbered
from 1 to 5. Legal combinations allow the buttons to be pushed in specific
order either singly or in pairs without pushing any button more than once.
Thus [(12), (34)] = [(21), (34)]; [(1), (3)]; and [(2), (13), (4)] are legal combinations
while [(1), (14)]; [(134)]; and [(13), (14)] are not.
(a) How many legal combinations are there?
(b) If a sixth button were added, how many legal combinations would
there be?
Cointainers again
arrive, one having an 11-pint container and another having a 2Npint
container. How will you most efficiently measure out 1 pint of drink
for each customer to drink in turn and end up with N pints in the 11-pint
container and 37-2N pints in the 37-pint container if
(a) N = 3;
(b) N = 5?
Nine single-digit numbers
of 45 and a product of 9! = 362,880.
Number:)
part has the following property. Divide the number by 3, reverse the digits
of the result, subtract 1 and you produce the original number. What is
the number and what is the next greater number (possibly with more than
three digits) having this property?
Cointainers
pint container starts out full, and the other two start out empty: (15, 0,
0). Through transferring liquid among the containers, measure exactly two
pints for yourself to drink and end up with 8 pints in the 10-pint container
and 5 pints in the 6-pint container. Find the most efficient solution.
Friday, September 11, 2009
Shaastra 2009 puzzles
these numbers in a 3X3 matrix such that the sum of the numbers in the first two
rows gives the number in the third row and if the paper on which this is written is
inverted, the sum still works. In other words, the inverted second and inverted third
row add up to give the inverted first row.
2. Mike, Steve, Dilbert, Charlie and Stuart gathered in a farm house at the outskirts
of the city to divide the loot and plan the next robbery. However, they came to
know that it could be dangerous for them to venture into the roads that night. Since
they were anyway going to stay, they decided to sleep and discuss the next day.
Mike woke up at night. He casually inspected the items and among other things,
notices a huge sack of gold coins. He wanted to get his share right then. So he
divided the coins into five sets, but one coin was left. He added the extra coin to
one set and hid that for himself. He went back to sleep.
Steve woke up (without knowing what had happened) after Mike. His attention also
was drawn to the sack. He divided the rest of the gold coins evenly into five sets,
but one coin was left. He added the extra coin to one set and hid that for himself.
He went back to sleep.
Dilbert woke up (without knowing what had happened) after Steve. His attention
also was drawn to the sack. He divided the rest of the gold coins evenly into five
sets, but one coin was left. He added the extra coin to one set and hid that for
himself. He went back to sleep.
Charlie woke up (without knowing what had happened) after Dilbert. His attention
also was drawn to the sack. He divided the rest of the gold coins evenly into five
sets, but one coin was left. He added the extra coin to one set and hid that for
himself. He went back to sleep.
Stuart woke up (without knowing what had happened) after Charlie. His attention
also was drawn to the sack. He divided the rest of the gold coins evenly into five
sets, but one coin was left. He added the extra coin to one set and hid that for
himself. He went back to sleep.
When they all awoke in the morning, they determined to divide the rest of the gold
coins evenly into 5 sets. Each of them got a set. Again one coin was left. How they
resolved the fate of the last gold coin is a story in itself. But can you find out the
number of gold coins each person got so far?
3. Grandpa Willard says he knows how to make the best applesauce in town. So
he's down at the Half-Off Dale's Deli telling his pals about it, and pretty soon there's
a big argument over which apples and which ingredients make the best applesauce.
At one point Dale had to ask them to be quiet as they were scaring off the other
customers. So, using the following clues, see if you can which apples and which key
ingredients go with which grandpa.
The ingredients that begin with a capital letter are varieties of apples (eg: Yellow
Transparent, Gravenstein) and the others are flavors (eg: lemon, cinnamon).
- Cooper hates Northern Spy apples and horseradish.
- Neither Smith nor Ted would allow lemon in his applesauce.
- McGee uses twice as many apples as John Willard.
- Neither Dick nor Cooper likes almond.
- Neil and Cooper can't stand Granny Smith apples.
- The one using almond extract, not Rod or McGee, uses 1 lb. apples.
- Grandpa John uses 0.5 lb. more apples than Grandpa Frandsen.
- The grandpa using 2.5 lbs. does not care for cinnamon.
- The one using three teaspoons of horse radish also uses Northern Spy apples.
- The grandpa using brown sugar (2 c) uses 1.5 lbs more apples than the one using
Granny Smith apples.
- Ted and Cooper both disdain Yellow Transparents.
- Neil likes Northern Spy apples. He uses three times as many as the one who uses
almond extract.
- Delicious apples and brown sugar go together, claims Rod.
- Grandpa Smith uses 4 oz. of flavoring with his Gravenstein sauce, 3 oz. more than
Ted.
(Hint: There are only 5 grandpas present, including Grandpa Willard.)
4. A square birthday cake measures 12 inches by 12 inches and is 6 inches high.
Three children wish to share the cake equally. But simply dividing the cake into
three pieces isn't good enough; the cake has chocolate frosting on all sides except
the bottom, and each child wants to have the same amount of chocolate frosting as
well as the same amount of cake. Since there is a rose made of icing in the center
of the top of the cake, and the birthday boy wants the entire rose, no cut may pass
through or touch where the rose is. How will you divide the cake?
5.An alien ship has invaded earth and has taken humans as prisoners. They are put
in numerous circular cells suspended by some mechanism. The cell is being filled by
a poisonous gas which will kill them slowly, but surely. The wall of the cell, which is
a cylinder, has four push buttons placed symmetrically. the push buttons have two
states ,"on" or "off". But the occupants would not come to know, by any means,
what state the push button is presently in. The prisoners would be free if the push
buttons are all in the same state, i.e. all "on" or all "off". The prisoners are allowed
to press any button any number of times in a bid to get free. But the problem is
after every wrong "try", the wall of the cell will spin for 30 seconds and come to a
halt. This ensures the prisoners have no way of telling which buttons they tried. A
"try" consists of 1,2,3 or all four of the buttons being pushed simultaneously. When
a button is pushed, its state changes, i.e. on becomes off and vice versa. Tell
whether they will be able to get out of the cell within 5 minutes (the time within
which the deadly gas will surely kill everyone). Support your answer with suitable
explanation.
AlgorithmhtiroglA
2...Find a two-line program to output the Nth Fibonacci number.
3...Given text, count the words inside.
you are reminded ".", ",", "?" could also be separator, plus number like "123,456,789.012" where '.'/',' not considered as separator...
The question is more about requirement and definition.
E.g. how many words in the string below?
"ab $2,300.58?2,,300.58 123?.235"
4...Find the longest palindromic substring in a string.
5...Given a n*m matrix having numbers such that each row and each column sorted. Now print the numbers in present in the matrix in sorted order.
6...Given a binary tree, prove that it is a BST(Binary search tree), without using inorder traversal either recursively or iteratively..?
7...Given an n*n matrix A. Each row of the matrix and each column of the matrix is sorted.
Given a number S, you are required to find S in the matrix( report k, l such that A[k,l] = S) or conclude S is not in A.
How can you solve it in O(n)?
8...A String as given as input in the form of Hex Decimal format and you need to print the ASCII format.
9...Print a binary tree in zig zag way... that is:
......a.........
....b....c.......
..d...e...f...g..
.h.i.j.k.l.m.n.o.
should be printed as a-c-b-d-e-f-g-o-n-m-l-k-j-i-h
what data structure will u use for that?
10...Write a function to reverse a line(i.e "How are you" will become "you are How")
11...give you two strings, one source string, one pattern string, check if they are totally match. The pattern string could include '?' which can replace one character. The pattern string could also include '*' which can replace multiple (0-n) characters. For example,
1. src = "abcde", pattern = "ab?de", return true.
2. src = "abcde", pattern = "a*d?", return true.
3. src = "abcde", pattern = "*fg", return false.
12...Given an integer n. Create an array of elements between 1..n in random order in the array. The probability of choosing a number for any position in the array should be the same.
13...How to identify bits that alternate 1 and 0. Ex: 101010, 10101, 01010, 01.
15...You have a random 5 function. Generate a random 7 function using this random 5 function with equal probability
Arrays!!!
2...Given an int array and an int value. Find all pairs in array that add up to value.
3...Given an array of size n, you have n-1 integers in the array, and one of the n elements is a duplicate, find an efficient method of finding the duplicate.
4...Given a sorted array and a value, determine the first pair of numbers from that array which sums up to the given value.
5...Given two Arrays, there is intersection of elements in these two arrays. So now find all the elements which are common in both these arrays.
Suppose there is an element '#' repeated 2 times in both the arrays, then in the output we need to show two '#'s
6...How to efficiently find most frequent element in an array.?
7...Given an array of integers,Print the integers whose appearance are in odd times.
Need not worry abt order while printing the output.
Need Algorithm in o(n) time complexity.
Need efficient space complexity.
8...Given an integer array {1, -20, 29, 9, 1, 100, ..., 29), please return the index of the first non-repetitive element in the array.
9...Given a set S of n distinct numbers and a positive integer k <= n. Determine the k numbers in S that are closest to the median of S. Find an O(n) algorithm
10...Given 2 sorted arrays of n elements A,B. Find the k-th smallest element in the union of A and B in O(log k) time. You can assume that there are no duplicate elements
11...How do you perform binary search on a rotated sorted array?
eg., 75, 77, 85, 91, 10, 19, 26, 29, 33,45, 67
12...Given an array of integers where some numbers repeat 1 time, some numbers repeat 2 times and only one number repeats 3 times, how do you find the number that repeat 3 times.
13...Given an array of positive numbers and negative numbers devise an algo to find max non-consecutive sum in that array.complexity should be in o(n).
14...Find the k max elements in an array of n
15...Find the sum of the most common element in a array .
16...Find a median of two sorted integer arrays.
17...Write a function that takes in an array of integers and outputs the number of ways you can combine those integers to obtain a sum of 15.
Example: for [10,5,3,2], output = 2.
18...Given an array of integers, write a function that returns the difference between the largest even integer and the smallest odd integer.
Sample input: [17 6 13 31 2 8 23]
Correct sample output: –5 (= 8 – 13)
19...I have an array that contains integers 1...n.
I remove 2 elements from that array, shuffle it and give it to a function you will write.
Find the 2 elements i removed.
Friday, August 21, 2009
AthenaHealth interview
1)Let’s play a game of Russian roulette. You are tied to your chair and can’t get up. Here’s a gun. Here’s the barrel of the gun, six chambers, all empty. Now watch me as I put two bullets in the gun. I close the barrel and spin it. Should I spin the barrel or not so that you could be alive.
2)Luckily you survived. Now again i am pointing it at you. Should I spin the barrel or not so that you could be alive.
3)Find the last non-zero digit of 30^2345
4)A man visits a shopping mall almost every day and he walks up an up-going escalator that connects the ground and the first floor. If he walks up the escalator step by step it takes him 16 steps to reach the first floor. One day he doubles his stride length (walks up climbing two steps at a time) and it takes him 12 steps to reach the first floor.
If the escalator stood still, how many steps would there be on sight?
5)A rectangular ground is to be filled with square tiles of unit area. The border of the ground should be of red coloured tiles and inside white. If the number of red and white tiles are the same, find the minimum dimensions of the ground.
6)N people were in a party and were seated in a circular manner. If each of the two present in the party, except the pairs that were adjacent,sang a song and If a song lasted for 2 mins and 28 mins was taken for singing the songs, find N.
7)3 pirates have to decide how to divide their loot of 100 gold coins. The rules are as follow:
* The most senior pirate gets to propose a way to divide the loot.
* Each pirate, including the most senior pirate himself gets to vote.
* If the majority agrees with the proposal, the loot will be divided as suggested.
* In the case of a tie, the proposal will be accepted.
* If the majority disagrees, the most senior pirate will be killed. The next most senior pirate gets to suggest. The process continues.
Now, you're the most senior pirate out of the three. How are you going to divide the coins so that you get the biggest share possible?
8) Find the number of solutions for 3x+4y=60, if x and y are positive integers.
9)There are 25 Horses which all run at different speeds. A faster horse always beats a slower horse. You can race 5 horses at a time. There are no ties and you may not time them. What is the minimum number of races needed to determine the 3 fastest horses in order from fastest to slowest.
The second round was an interview which lasted for 10-20 mins. Some simple programs and puzzles were asked along with some basic HR questions.
For eg. Program to build a pyramid of stars, Defective soap box puzzle, Tablets in two bottles puzzle.
Some were asked to tell some real time examples for normalization, queues and priority queues.
A sound knowledge in puzzles along with some programming skills will help you clear this round.
The third round was a programming round where 3 questions were asked(Time duration: 1 hour)
1)To encrypt a given passage according to the given pattern.
2)To find the day given the date.
3)To print the roman number for a given decimal number.
Thorogood Interview
i)analytical >>>>> One hour was given with 5 questions 3 questions were logical questions , 1 was a data sufficiency question and 1 was a data interpretation from a chart and a graph.
I am able to collect only one of the questions asked
Each of five friends A,B,C,D,E placed bets amongst themselves. Each person placed atmost one bet against wuth every other person and none of the bets ended as a draw. The money involved in each bet is called stake of the bet.The total money got by any person in all the bets is called as his gain and the total money lost by any person in all the bets is called as his loss.The following info was also known:
1)No two persons won the same number of bets and No two persons lost the same number of bets.
2)For any two persons the stakes of any two persons were different.
3)The stake of any bet was an integer amount and is neither less than Rs.4 nor more than Rs.21.
4)Neither the gain of any person who won atleast one bet nor the loss of any person who lost atleast one bet is less than Rs.20 or more than Rs.40.
5)The sum of the stakes of all the bets placed by A,B,C,D,E are 55,37,40,55 and 53 respectively.
6)The number of bets won by D is equal to the number of bets lost by A. The number of bets lost by C is more than the number of bets lost by D.
7)E won Rs.17 against A and the stake involved in the bet between C and D is Rs.4.
The gain of A is equal to the loss of D.
Q1)The person who won the maximum number of bets is
a) A b) B c) C d) D e)E
Q2)The person who won the same number of bets as he lost
a) A b) B c) C d) D e)E
Q3)The stake in the bet between B and C is .....
Q4) What is the total loss of A?
ii) The second section was for 30 mins. The following questions were asked
.)You plan to go for a film with your friends. But your friends gave another option but you were very keen on watching the movie of your choice. What would you do now?
.)The food in your mess is not good. Some may continue with that, some others will go out and eat and some others will complain the officials concerned. what will you do and why?
.)You are on a project and you have a excellent project guide. The company forces you to work on a completely new language. How will you react to this
.)What you dont like in a company
Two more questions were on success and perseverance.
The second round was a normal HR round which lasted for 15-25 mins.
For the next round the student had to go to Thorogood in Bangalore
The assessment process started with 'introduce yourselves ' (jus for 10 secs, name coll...). We had four rounds that lasted for the whole day.
FIRST ROUND (FACT FINDING)
I was given a situation like this :
Your friend's job is transferred to the city where you reside. He and his family members have never visited this city before. Your friend requests you to get him a house. You have 4 properties at hand and one week time to decide on.
After explaining the situation,the resource person gave me 10 minutes time to write down all the questions that i should ask her to know more about the problem,10 minutes time to ask her those questions and to write down the answers. At the end of the 10th minute i had to give my answer. They questioned me for 15 minutes where i had to justify my decision.
Here, they tested us based on our listening skills, ability to obtain clear and complete information about the issue from the client, analyzing on the requirements and proposing a solution that fits most of his requirements and finally our ability to convince the clients.
COMPANY PRESENTATION
We were given 1 hr 30 minutes time to read a 7 page company problem sheet and prepare slides containing our solution. We were given 10 minutes to present our solution in front of the panelists.
It was something like devising a strategy for 6 months for selling three products in two markets assuming that you are the CEO of some company XYZ.
We were questioned for 15 minutes from our presentation.
Here they tested skills like ability to understand a business scenario from the given data,
ability to propose a feasible solution within the given time, presentation skills, ability to convince the panelists and tackle unfavorable situations.
GROUP EXERCISE
Again a business scenario. We were given 15 minutes to go through the scenario and prepare a presentation for 3 minutes in a flipchart in front of the group.
After everybody had their turn, we were given 35 minutes to discuss among ourselves and decide on a common plan. It was like a typical company group discussion where we were concentrating on all the problems they had mentained in the comapany scenario and were trying to bring out a feasible solution. We were monitored by 6 people. The final plan had to be posted on the board at the end of the 35th minute.
No idea how they tested us. The conference hall sounded like a fish market. Survival of the fittest actually.
PERSONAL INTERVIEW
A typical HR interview.
We were individually monitored throughout the assessment process. They noticed everything starting from how we spoke to the guards outside, how we behaved inside the kitchen , how we moved with the other college students . They showed us their company presentation again and this was done in detail this time. They noted how attentive we were during the presentation, our interest in joining the company etc.
We will never know on what basis the company recruits its employees. The best thing, i think ,is to just be constantly conscious of the environment and trying to project the best qualities in us wherever possible.
Sunday, August 9, 2009
Subex Programming
2. Given a set of words in command line we need to list the words sorted by frequency, if frequency is of same degree we need to sort it alphabetically.
Eg. abb baa abb abb baa aaa aaa
o/p: abb aaa baa
3. Given a text file we need to wrap the text according to the given number n. If the end of the line consists a space or a tab we continue as usual else if a word is present we have to hyphenate it.
The phone interview was a technical interview.
Basic definitions on trees, trie structure, normalizations, operating system, unix commands were asked.
some questions were asked on .NET and AJAX too.
Knowing all the definitions will help you clear this round.
Monday, July 27, 2009
some of Subex c questions
void main()
{
int arr[]={0,1,2,3,4,5};
int i;
int *p=arr;
*p+2=10;
for(i=0;i<6;i++)
printf(“%d\n”,arr[i]);
}
2. enum marks
{
che, phy=53, math;
};
struct s
{
char name[15];
enum marks m;
}k;
void main()
{
strcpy(k.name,”Tom”);
k.m=phy;
printf(“name:%s\n”,k.name);
printf(“Physics marks:%d\n”,k.m);
k.m=che;
printf(“chemistry marks:%d\n”,k.m);
}
3. What is the o/p of the following statement?
cout<<(100==100);
4. void main()
{
extern int i;
i=20;
printf(“%d”,i);
}
5. void main()
{
int i=5;
int arr[]={-1,2,3,4,5};
for(;i==0;i++)
printf(“%d\n”,arr[i]);
}
6. void main()
{
int i=5,k;
k=++i==6;
printf(“%d\n”,k);
}
7. void main()
{
int size=10;
int arr[size];
printf(“%d”,sizeof(arr));
}
8. #include
#define first 5
#define second 7
#define last first+second
void main()
{
int i;
i=last*last;
printf("%d",i);
}
9. #include
struct s
{
int i;
struct s p;
}k;
void main()
{
k.i=10;
printf("%d",k.i);
}
10. void main()
{
char ch;
scanf(“%c”,&ch);
printf(“%c\n”,ch);
scanf(“%c”,&ch);
printf(“%c\n”,ch);
}
If ‘a’ is given as i/p o/p will be
a
a
If 4 ‘a’s are to be printed,(i/p,o/p,i/p,o/p) the fflush() function should be used.
11. void main()
{
char s1[]=”hi”;
char s2[]=”hi”;
if(s1==s2)
printf(“same”);
else
printf(“Different”);
}
Saturday, July 25, 2009
A puzzle to ponder
It has come into notice that moving weights into and out of the pan of the balance takes time and this time depends on the number on the number of weights that are moved. For example - If we need to measure 4 kg using weights 1 and 3 only, it will take twice as much time needed to measure 1 kg. Lets say we want to make sugar packets of weights 1,3,4 using weights 1 and 3 only. For this first we measure 1 kg, with 1 unit of time, we place 3 kg along with 1 kg and measure 4kg with again 1 unit of time, and finally we move 1kg out of pan to measure 3kg in 1 unit of time. So in 3 units of time we could measure 1,3 and 4kg using weights 1 and 3 only.
Now you have to make sugar packets of all weights from 1 to 125 in minimum time, in other words in minimum movement of weights. The question here is to find out the minimum number of weighs needed and the weight of each the weights used and the strategy to be followed for the creation of 125 packets of sugar.
Classic MS problem
* You have access to a 100-storey building.
* Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical.
* You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking.
* Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process
Party confusion




If you are a genius answer it in 10 seconds

The chessboard has been the source of all kinds of puzzles that
explored mathematical ideas, ever since it came into use centuries ago. One
that finds its way into virtually every puzzle anthology because of its
apparent difficulty, yet deceptively simple solution, is the following:
If two opposite corners of a checkerboard are removed, can the
checkerboard be covered by dominoes? Assume that the size of each
domino is the size of two adjacent squares of the checkerboard. The
dominoes cannot be placed on top of each other and must lie flat.
Rip the blindfold
have either a red or a blue cross painted on her forehead. When the blindfolds
are removed, each woman is then supposed to raise her hand only if
she sees a red cross and to drop her hand when she figures out the color of
her own cross. Now, here’s what actually happens. The three women are
blindfolded and a red cross is drawn on each of their foreheads. The blindfolds
are removed. After looking at each other, the three women raise their
hands simultaneously. After a short time, one woman lowers her hand and
says, “My cross is red.” How did she figure it out?
This question gave us a new idea
cage. How many pairs of rabbits will be produced in that cage in a
year if every month each pair produces one and only one new pair,
consisting again of a male and a female, which, from the second
month of its existence on, also is productive? It is assumed that none
of the rabbits die in that year.
UNLUCKY BREAKDOWNS
banded together for a day's outing and pleasure. They pressed into service
nearly every wagon in the place, and each wagon was to carry the same num-
ber of persons. Half-way ten of these wagons broke down, so it was necessary
for every remaining wagon to carry one more person. Unfortunately, when
they started for home, it was found that fifteen more wagons were in such bad
condition that they could not be used; so there were three more persons in
every wagon than when they started out in the morning.
How many persons were there in the party?
WHEN DID THE DANCING BEGIN?
"thought that the clock had stopped, because the hands appeared in exactly
the same position as when the dancing began. But it was found that they had
really only changed places. As you know, the dancing commenced between
ten and eleven oclock. What was the exact time of the start?"
Sunday, May 17, 2009
Simple one
A student wrote all the natural numbers from 2 to 10000 on a blackboard, one after the other. Another student came and erased all the perfect squares from among the numbers written. Another student came and erased all the perfect cubes. If students come this way and erase all the higher powers, find the number of students who erase at least one number.
Friday, May 1, 2009
Problems of weights
example:wt entered by the user is 19kg
we can make 19 as....27-9+1
hence the output wil be 1,9,27
similarly for 62 81+9-27-1
hence output will be1,9,27,81
Friday, January 16, 2009
The ball problem
Allan took out 2 red balls from his bag. After he compared the label he told Mr. Singsong what the color of the third ball was immediately.
Brian took out 1 red ball and 1 white ball from his bag. After he compared the label he told Mr. Singsong what the color of the third ball was immediately also.
Charlie took out 2 white balls from his bag. After he compared the label, he could not tell what color of the third ball was.
However, David said to Mr. Singsong: I can tell what color of all my 3 balls are. He did it correctly. But how?
Also, can you tell what label said and what kind of balls each person had
Logic
Someone asked them: Who is older?
The sister said: I am older.
The brother said: I am younger.
At least one of them was lying. Who is older?
Are you a maniac of programming?
2.Asked in 1st and 2nd interview at campus placement at IIIT Gwalior.
8 x 8 char array is provided with random letters. You have to tell if a given string occurs.
eg
String to find = "computer"
Array[] = {
b b b b b b b b
b b b c b b b b
b b o b b b b b
b b b m p b t b
b b b u b u b e
b b b t b b b r
b b b e b b b b
b b b r b b b b
}
ans:possible
3.There are n petrol bunks arranged in circle. Each bunk is separated from the rest by a certain distance. You choose some mode of travel which needs 1litre of petrol to cover 1km distance. You can't infinitely draw any amount of petrol from each bunk as each bunk has some limited petrol only. But you know that the sum of litres of petrol in all the bunks is equal to the distance to be covered.ie let P1, P2, ... Pn be n bunks arranged circularly. d1 is distance between p1 and p2, d2 is distance between p2 and p3. dn is distance between pn and p1.Now find out the bunk from where the travel can be started such that your mode of travel never runs out of fuel. DO it in linear time...
4.Propose a tree based data structure to identify a node with nth rank with maximum efficiency .
5. How will you find the first k smallest elements in a given unsorted array in O(n) at the worst case?
6.A 2D array is such that each row in it is in ascending order and each column is in ascending order. How will you search for an element in this array? (O(n) is enough)
7.A tree is represented in a matrix form such that A[i,j] = 1 if j is the ancestor of i. Otherwise A[i,j] = 0. Given this construct a normal binary search tree.