![]() ![]() First, move disk 1 and disk 2 from source to aux tower i.e.Then, move the 3 rd disk from source to dest tower i.e.And finally, move disk 1 and disk 2 from aux to dest tower i.e.$$TowerofHanoi(n, source, dest, aux) = \text-1$ Hence, the recursive solution for Tower of Hanoi having n disks can be written as follows, (again move all (n-1) disks from aux to dest. The minimum number of steps required to move n disks from source to dest is quite intuitive from the time complexity analysis and also from the raw examples as shown in the table, Hence, the time complexity of the recursive solution of Tower of Hanoi is O(2n) which is exponential. Minimum steps required to move n disks from source to destįrom the above table, it is clear that for n disks, the minimum number of steps required are 1 2 1 2 2 2 3 . ![]() 2 n-1 which is a GP series having common ratio r=2 and sum = 2 n - 1. TOWER OF HANOI PROGRAM IN C USING GRAPHICS IN MULTIMEDIA SERIES Hence, the Tower of Hanoi puzzle with n disks can be solved in minimum 2 n−1 steps. TOWER OF HANOI PROGRAM IN C USING GRAPHICS IN MULTIMEDIA SERIES. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
March 2023
Categories |