Tower of Hanoi Algorithm:
Start
Define function
Declare variable n
Enter the number of disc
Call the function
Stop
Algorithm for Function Definition
if n=1
print Move disc 1 from fr to tr
Call the function with n-1, fr, ar, tr
Move disc n from fr to tr
Call function with n-1, ar, tr, fr
Return
Start
Define function
Declare variable n
Enter the number of disc
Call the function
Stop
Algorithm for Function Definition
if n=1
print Move disc 1 from fr to tr
Call the function with n-1, fr, ar, tr
Move disc n from fr to tr
Call function with n-1, ar, tr, fr
Return
No comments:
Post a Comment