Tower of Hanoi is a very famous game. In this game there are 3 pegs and N number of disks placed one over the other in decreasing size. The objective of this game is to move the disks one by one from the first peg to the last peg. And there is only ONE condition, we can not place a bigger disk on top of a smaller disk.
Tutorial and Code:
In this video we will learn to solve Tower Of Hanoi recursively by taking minimum number of moves.
0:03 About Tower Of Hanoi
0:18 Important rule to follow while solving Tower Of Hanoi
0:25 The three pegs of Tower Of Hanoi labeled A, B and C
0:33 The 3 disks in decreasing size from bottom to top
0:38 Objective of the game
0:51 How to solve Tower Of Hanoi
0:58 The general notation used to solve the Tower Of Hanoi problem recursively
1:15 The 3 steps to follow recursively to solve Tower Of Hanoi
1:50 Solving the game with 3 disks
2:05 Calculating the minimum number of moves to solve Tower Of Hanoi recursively
2:10 Solving T(3, A, B, C)
3:05 Solving T(2, A, C, B)
3:58 Solving T(2, B, A, C)
4:55 So we have the moves. Lets see them in action!
6:15 Algorithm of Tower Of Hanoi (Recursive)
6:42 Calculating minimum number of moves to solve Tower Of Hanoi having N disks
You can download the code from my GitHub repository
To know more about Pseudo code kindly watch this video