GATE Computer ScienceVery hardGATE CS (PYQ pattern)

The Tower of Hanoi with 6 disks is played on three pegs in a row (left, middle, right), and a disk may move only between adjacent pegs. What is the minimum number of moves to transfer all disks from the LEFT peg to the MIDDLE peg?

  1. A. 728
  2. B. 364
  3. C. 63
  4. D. 365

Correct answer: B. 364

Moving the stack left→middle: shift the top 5 disks left→right (adjacent-only, 3⁵ − 1 = 242 moves), the big disk left→middle (1), then the 5 disks right→middle (A(5)). So A(n) = 3^(n−1) + A(n−1), A(1) = 1, giving A(n) = (3ⁿ − 1)/2 = 364. 728 = 3⁶ − 1 is the left→right count; a BFS over all 3⁶ states confirms 364.

More Algorithms questions

Exams that ask this topic