retagged by
2,870 views
20 votes
20 votes

You are given ten rings numbered from $1$ to $10$, and three pegs labeled $A$, $B$, and $C$. Initially all the rings are on peg $A$, arranged from top to bottom in ascending order of their numbers. The goal is to move all the rings to peg $B$ in the minimum number of moves obeying the following constraints:

  1. In one move, only one ring can be moved.
  2. A ring can only be moved from the top of its peg to the top of a new peg.
  3. At no point can a ring be placed on top of another ring with a lower number.

How many moves are required?

  1. $501$
  2. $1023$
  3. $2011$
  4. $10079$
  5. None of the above.
retagged by

3 Answers

Best answer
17 votes
17 votes
I think its Tower of Hanoi problem.
Therefore, total number of function call $2^{n} -1 = 1023$.

 $\therefore$ Option $B$.
edited by
13 votes
13 votes

it is a tower of hanoi problem. we can see recurrence relation for moves.

number of moves:

$T(0) = 0$

$T(1) = 1$

$T(2) = 3$

$T(3) = 7$

$T(4) = 15$

.

.

.

$T(10) = T(9) +T(9) +1$

$T(n) = T(n-1) +T(n-1) +1$

 $T(n) = 2T(n-1) +1$

           $= (2^n)-1$

           $=1023$

 so B is ans

edited by
Answer:

Related questions