Tower of Hanoi In the original version of the Tower of Hanoi puzzle, as it was p
ID: 441282 • Letter: T
Question
Tower of Hanoi In the original version of the Tower of Hanoi puzzle, as it was published in the 1890s by Edouard Lucas, a French mathematician, the world will end after 64 disks have been moved from a mystical Tower of Brahma. Estimate the number of years it will take if monks could move one disk per minute. (Assume that monks do not eat, sleep, or die.) How many moves arc made by the ith largest disk (1 i n) in this algorithm? Find a nonrecursive algorithm for the Tower of Hanoi puzzle and implement it in the language of your choice.Explanation / Answer
a)2^64-1 minutes b)2^i-1 c) function TowersOfHanoi (Pole S, Pole T, Pole D, Integer n) { IF [ n == 0 ] THEN RETURN ENDIF TowersOfHanoi (S,D,T,n-1); PRINT ("Move disk no 'n' from 'S' to 'D'"); TowersOfHanoi (T,S,D,n-1); }
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.