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:10 Solved!

6:15 Algorithm of Tower Of Hanoi (Recursive)

6:42 Calculating minimum number of moves to solve Tower Of Hanoi having N disks

Related Videos

Factorial

Fibonacci

You can download the code from my GitHub repository

To know more about Pseudo code kindly watch this video

Thanks 🙂

Nguồn: https://inst-wd.com/

Xem thêm bài viết khác: https://inst-wd.com/game/

Nice !

I found out to do this in a minute. No joke.

was literally expecting an Indian accent

Wonderful it really help me to find the complexity of Tower of Hanoi Thankyou so much

Finally got this! Thank you so much!!!

Tomorrow exam

thank you . ı tangled ı haven t consider this is quite easy

Amazing! Thank you very much!!!

Bhai kuch bol bhi le 🤐🤐

Hi! I'm from Argentina. I tried to figure out my self this algorithm, but I couldn't. But I think I actually figured out the formula in the end, the one that returns the minimum of movements to solve a level. But my formula is different! (Also is less useful, but well I'm only a secondary student haha). Mine it's like this:

T(n) = 2T(n-1) + 1

T it's the "tower of disks" and n is the number on disks. For example, as you said, the minimum movements for a 3 disks tower is 7. For a tower of 4 disks, It will be 15 movements (7×2+1). For a tower of 5, 31 movements. 6 disks, 63 movements…. And so on. I discovered another things but I don't want to make really long comment so I will stop here :). Very good video, loved it!

Amazing. Loved it

Your are a god

3 is easy but not 7

Who coming because of the silly game?

cant you just move the top one on the left to the close right each time, and when finished, move the top middle to the close right side everytime its solved isnt it?

this is wrong, you have wrote Aux=A in beginning than in the middle you changed it into Aux=C why???????

How is it you know you have made correct moves prior to the completion of the recursion? I'm thinking you put a lot of knowledge in your algorithm rather than letting the recursion do the work. Which I suppose is fine, but I would have preferred an exhaustive analysis that uses the recursion instead of using knowledge of the problem to solve it. Yes, this is more clever, and such, but it's not a great example of recursion, IMO.

One of the best I've seen so far.

Ise kahte Bina bole isaro me samjhana

Great, Thanks

Nice video

It's the best out on YT.

How is it move A -> C ??

Bosdka sound kha h

No sound….but nice video

The best explanation of tower of honoi puzzle….on youtube…..

You are the only who explained well each step for the resolution of the Tower of Hanoi and how to get the moves. Nice video, thank you.

thank you mister

Tq u so much sir. I've seen many videos of this game but no video is in detailed explanation as udid even without sounds

Yusuf great effort. Keep it up.

😶A guy demonstrates..Working example of Tower of Hanoi. https://youtu.be/KUgBiQpMkZI