Towers of hanoi problem.
3 poles, N discs in decreasing size. (seen bottom to top, usual)
but there is one new condition. There are i number of discs (of same size i) at each ith position. A disc can be placed on top of same or bigger sized disc.
complete the below function to move all discs to another pole.
int getNumMoves(int N)
{
}
You will be given input number N, you have to output number of moves needed.
For ex:
For N = 3 NumMoves is 17
For N = 4 NumMoves is 49
Tuesday, April 5, 2011
Monday, April 4, 2011
Least number of trips to number the wires
There is a bunch of 120 electrical cables laid under the ground. The cables are 10 KM in length and both ends of each wire are out in open.
We need to identify and label the cables 1-120. All you have is a circuit completion detector bulb.(i.e. if you join same side ends of any two cables and then on the other side apply the bulb to corresponding 2 ends then bulb will light up, but to detect this way you have to make a 10 KM trip)
How would you identify each cable in minimum number of trips.
NOTE: The answer is very very low, so think it out.
If need any clarification please ask.
We need to identify and label the cables 1-120. All you have is a circuit completion detector bulb.(i.e. if you join same side ends of any two cables and then on the other side apply the bulb to corresponding 2 ends then bulb will light up, but to detect this way you have to make a 10 KM trip)
How would you identify each cable in minimum number of trips.
NOTE: The answer is very very low, so think it out.
If need any clarification please ask.
Algo to achieve maximum height
You are given wooden cuboids with certain length, width and fixed height.
You have to place them one above the another with condition that whenever a cuboid is palced over another, its lenght and width should be within the lower cuboid. (less than or equal to).
Create an algo to achieve optimum height for given set of cuboids.
You have to place them one above the another with condition that whenever a cuboid is palced over another, its lenght and width should be within the lower cuboid. (less than or equal to).
Create an algo to achieve optimum height for given set of cuboids.
Find out height of the Tree
There is a tree on the edge of bank of a river and you are standing on opposite side.
You have a 1 metre stick with you. How do you measure the height of tree without leaving your side (i.e. not crossing the river).
You have a 1 metre stick with you. How do you measure the height of tree without leaving your side (i.e. not crossing the river).
Subscribe to:
Comments (Atom)