



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Using this link ( https://www.mathsisfun.com/games/towerofhanoi.html )
So, we find that for a given N of disks, the way to solve a problem in a minimum
number of steps is:
Therefore, the recurrence relation for this puzzle would become:
*H n = 2 H (n- 1 ) + 1
inter, destination}.
Counter 0 \num of moves tower (n: disk, source, inter, destination) IF n = 1 , THEN Counter Counter + 1 Print “move disk from “ + source + “to ” + destination ELSE Counter Counter + 1 tower (disk - 1 , source, destination, inter) Print “move disk from “+ source +”to “ + destination tower (disk - 1 , inter, source, destination) END IF END Return ( Counter )