Describe a recursive solution to the Towers of Hanoi puzzle with N disks.

What will be an ideal response?


The solution is:
(1) Move the top N-1 disks to the extra peg.
(2) Move the largest disk from the original peg to the destination peg.
(3) Move the N-1 disks from the extra peg to the destination peg.
The first step is the same problem again, with the extra peg and the destination peg interchanged, and therefore this
subproblem can be solved recursively. The base case is when N = 1, in which case we simply move the disk without any
recursive call.

Computer Science & Information Technology

You might also like to view...

A group of smart spaces are connected only by a space between them such as a hallway or square. Discuss the factors that determine whether that intervening space can act as a mix zone

What will be an ideal response?

Computer Science & Information Technology

Which of The following are encrypted protocols? (Select TWO)

A. TELNET B. SSH C. POP3 D. FTP E. HTTPS

Computer Science & Information Technology

The Mac OS reduces file fragmentation by using _______________.

A. ?inodes B. ?superblocks C. ?clumps D. ?chunks

Computer Science & Information Technology

Which of these PC cases has the largest footprint?

A. Laptop B. Desktop ATX case C. Small form factor case D. No significant differences between these footprints

Computer Science & Information Technology