Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of the following can be used to solve the Tower of Hanoi Problem ?

  • A.Recursion
  • B.Procedural
  • C.Divide and conquer
  • D.None of the above

Answer: A

The Tower of Hanoi is solved by Recursion.

To move n discs from peg A to peg C: move the top n-1 discs to peg B, move the largest disc to C, then move the n-1 discs from B onto C. Each step uses the same procedure on one disc fewer, ending with a single disc, and it takes 2n - 1 moves.

'Procedural' is a programming style, not a method of solution. The recursive solution does break the problem into smaller ones, but they are the same problem one disc smaller, done one after the other, which is why it is the standard example of recursion rather than of divide and conquer.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.