Tower of Hanoi | Recursion Problem | GeeksforGeeks

preview_player
Показать описание
Tower of Hanoi - A famous mathematical puzzle where we have three rods (A, B, and C) and N disks.
The disks are all stacked on Rod A in decreasing value of diameter i.e., the smallest disk is placed on the top.

Let us see how to solve Tower of Hanoi problem with the help of a Recursive Solution.

-------------------------------------------------------------------------

-------------------------------------------------------------------------

📖 Want to Learn more about Data Structures and Algorithms?

-------------------------------------------------------------------------

Follow us for more fun, knowledge, and resources:

Related Queries:
DSA problems
Recursion Problem
how to solve tower of hanoi problem
tower of hanoi explanation
recursion interview question
recursion practice problem
what is tower of hanoi

#towerofhanoi #recursion #recursive #recursiveproblem #dsa #datastructuresandalgorithms #dsaproblems #mathematicalpuzzle #recursivesolution #stack #puzzle #gfg #geeksforgeeks #geeksforgeekspractice
Рекомендации по теме
Комментарии
Автор

For n disks, total 2^n – 1 moves are required.

GeeksforGeeksVideos
Автор

the music is so appropriate for this...recursion feels like magic

sai-codes
Автор

I was out of mind the first time I saw this problem. This illustration is really brilliant. Now I have a good understanding of both recursion and the solution..

enisarik
Автор

2:17 pause the screen here, take a screenshot.
Then go to the code 3:50 and write down the code and write down on the code and then have a thorough look at it.

Now remember,
At 2:17 the actual "execution" of the code in the computer is from "top left to bottom right". (remember the N-1)
It kind of works in case of actual hanoi tower discs in the computer from down to up. (remember the N-1)

With these things in mind.
Keep both the 2:17 explanation and the code in your same view and keep going through it. Try to "Dry run it in your MIND" while looking at the solution.(or on a piece of paper)

At some point, it WILL CLICK. It might be frustrating but it will click. Once you understand how the EXECUTION is taking place, it'll way easier to grasp it.


P.s. try not to think about how you would manually solve this problem. Like first you'll move the topmost disc then another disc keeping in mind the rule that the smaller disc should be on top of a larger disc. Just forget about that for the moment and THEN approach the execution of the code. You'll get it...
(The rules that the smaller disc should be on top of a larger disc is just for you to understand. But we have to translate this logic to computer without explicitly saying it. If that makes any sense.)

ayushchoudhary
Автор

never did comment on an educational video before but this one was awe-inspiring beyond expectations...never knew the soundtrack has got this much influence on the audience irrespective of the realm of the video searched. The amalgamation of the soundtrack with the beautifully explained concept is truly remarkable. Education is beautiful if it is perceived more as a mean of entertainment than some sort of a tribulation and this video is the quintessence of the same.

_supravoroy
Автор

Hey you!
The person reading this comment!
Yes you!
You can be a successful person in the future, if you want to, just never stop learning, that's about CHOICE.
Best of luck!

asdfghjkl
Автор

Thank you GFG! That's the best and concise explanation on YouTube.

reetigarg
Автор

It's not one of the best video it's the best video available on youtube for recursive solution of tower of hanoi.
Simple, short, the

Anveshana
Автор

Thank you for your video! The unwinding of the stack really helped me understand the algorithm.

Fivousix
Автор

Honestly i watched a lot of videos regarding this problem and i understood how we are supposed to solve the puzzle but i Never understood how the code was to be written. I saw this video once and I was able to write the code on my own. I really love the approach you have taken

Wasaby
Автор

the music sounds so spooky!..the explanation is lit though!

babeetoon
Автор

I would prefer someone explaining to me instead of just text and music but it was a very beneficial video. Thank you!

Blender
Автор

Visualization + soundtrack is awesome. GFG should give Ishant Periwal a pay raise. Cheers!

pavithranravichandiran
Автор

As always GeeksforGeeks does it right! Thanks, your video is simply great. It truly is a visual lesson that helps me better understand this theory.

fsaforosaforo
Автор

I tried. Lord know I tried understanding this please.

obatochukwu
Автор

1:10-1:25 this simple illustration helped me out.

prabhaskoya
Автор

the music making me feel like i'm in Hogwarts flying in my magical broom doing magical maths

bjdtleu
Автор

This video was perfection itself. The soundtrack, the graphic, the solution. Brilliant.

RadagonTheRed
Автор

Im going to solve my life problems using recursion. Wish me luck!

LudwigvanBeethoven
Автор

So nicely explained
thank you so much for this video.

vijayasoni