Data Structures and Algorithms Question Towers of Hanoi problem: There is a boar
ID: 3684412 • Letter: D
Question
Data Structures and Algorithms Question
Towers of Hanoi problem: There is a board with three pegs and three disks of different sites (see Figure 1). The goaj of the game is to move the three disks from the peg where they have been placed (largest disk on the bottom, smallest disk on the top) to one of the empty pegs, subject to the following constraints: Only the top disk on a peg can be moved to another peg. A larger disk cannot be placed on top of a smaller disk. Design an algorithm to handle the Towers of Hanoi problem.Explanation / Answer
BEGIN
IF noOfTowers == 1 THEN :
Move the plate from source to dest;
else begin:
MoveDisk(disk - 1, source, intermediate, dest) ;
move disk from source to dest ;
end;
END;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.