Wednesday, February 15, 2012

Device An Algorithm to Find minimal number of moves the to pegs to transform from the initial to final configuration. .

There are K pegs. Each peg can hold discs in decreasing order of radius when looked from bottom to top of the peg. There are N discs which have radius 1 to N; Given the initial configuration of the pegs and the final configuration of the pegs, output the moves required to transform from the initial to final configuration. You are required to do the transformations in minimal number of moves.
  • A move consists of picking the topmost disc of any one of the pegs and placing it on top of anyother peg.
  • At anypoint of time, the decreasing radius property of all the pegs must be maintained.

No comments :