-
Given the values of two nodes in a *binary search tree*, write a c
program to find the lowest common ancestor. You may assume that both
values already exist in the tree.
The function prototype is as follows:
int FindLowestCommonAncestor(node* root,int value1,int value)
20
/ \
8 22
/ \
4 12
/ \
10 14
I/P : 4 and 14
O/P : 8
(Here the common ancestors of 4 and 14, are {8,20}.
Of {8,20}, the lowest one is 8).
-
Given an array of 2n elements of which n elements are same and the
remaining n elements are all different. Write a C program to find out the
value which is present n times in the array.
There is no restriction on the elements in the array. They are random
(In particular they not sequential.)
-
Given two arrays A and B. Array 'A' contains all the elements of 'B' but
one more element extra.....
Find out the extra element......
Restrictions: Dont use any relational ops ( > or > or == etc....), array
elements are not in order ...,
-
There are 2 cities A and B, dist. between them is 1000 Km
we have 3000 bananas in city A and a elephant can carry max 1000 bananas at
any given time and it needs to eat a banana every 1 Km.
How Many Max. No. of bananas one can transfer to city B?
Note : the elephant cannot go without bananas to eat.