Tower of Hanoi

The Tower of Hanoi puzzle consists of nn discs, no two of the same size, stacked on p3p \geq 3 vertical pegs, in such a way that no disc lies on top of a smaller disc. A permissible movemove is to take the top disc from one of the pegs and move it to one of the other pegs, as long as it is not placed on top of a smaller disc. Initially, they are all stacked on the first peg. The goal is to end up with them all stacked on the last peg.

Parameters

  • nn: number of discs
  • pp: number of pegs

Related Problems


Filters

Computational Model

Randomization

Approximation

Algorithms Table

Displaying 5 of 5 algorithms

See more
Hanoi graph2008O(3n)O(3^n)O(3n)O(3^n)
Iteration based1883O(2n)O(2^n)O(n)O(n)
Recursion based1883O(2n)O(2^n)O(nlogn)O(n \log n)
Non-recursion based1883O(2n)O(2^n)O(n)O(n)
Gray-code based1883O(2n)O(2^n)O(n)O(n)

Reductions Table

Insuffient Data to display table

Other relevant algorithms

Insuffient Data to display table