Towers of Hanoi: A Complete Recursive Visualization

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 พ.ย. 2024

ความคิดเห็น •

  • @boredpotato6366
    @boredpotato6366 4 ปีที่แล้ว +678

    If you keep making videos like this, you'll become the best and most famous CS teacher on TH-cam.

    • @codeoncloudtv7193
      @codeoncloudtv7193 4 ปีที่แล้ว +15

      I agree. Never see someone like him. So passionate

    • @Crandiddy4354
      @Crandiddy4354 4 ปีที่แล้ว +4

      The amount of ads on this video fucking disgusts me tho.

    • @lqv3223
      @lqv3223 3 ปีที่แล้ว +21

      @@Crandiddy4354 Man’s gotta make his bread. At this point, only 20 people support him on Patreon and he has tens of thousands of viewers who get such amazing content for free.

    • @Crandiddy4354
      @Crandiddy4354 3 ปีที่แล้ว +1

      @@lqv3223 He can't tone it down just
      a little? I mean for God sakes man, fucking 6 ads on a 20 min video.

    • @lqv3223
      @lqv3223 3 ปีที่แล้ว +3

      @@Crandiddy4354 That sounds like a lot tbh. A portion of my premium membership fee goes towards this channel, making it easier to support this channel and guarantee an ad-free experience. I'm sure he'll tone down the number of ads once he has a decent number of subscribers.

  • @JamesJon1187
    @JamesJon1187 3 ปีที่แล้ว +362

    If anyone else had didn't immediately catch the logic behind the " other = 6 - (start + end) ", it's because if you tally up the values of rods 1,2, 3 that will equal six. Thus if start = rod 1 and end = rod3, 6-(rod1+rod3) = rod2, thus "other = rod2".

    • @mohammedsuhail1500
      @mohammedsuhail1500 2 ปีที่แล้ว +19

      u made my day thank you:)

    • @ryannickles3218
      @ryannickles3218 2 ปีที่แล้ว +18

      I was just about to say that "6" appears to be a *magic number* that should be defined based on core principles. Thank you for elucidating.

    • @isaiahpaul56
      @isaiahpaul56 ปีที่แล้ว +1

      @@ryannickles3218 lol same

    • @thomaslao9832
      @thomaslao9832 ปีที่แล้ว +3

      unless you are using indices to store values or calculating distance between indices or having some kind of significance with adding up the labels of the rods, im going to call that "logic" presented in the video magic numbered bullshit for the sake of pseudo-genius content.

    • @mohammadraddad9446
      @mohammadraddad9446 ปีที่แล้ว +2

      so if I had 4 rods it will be (1+2+3+4) => 10-(strat+end)?

  • @leonardofillipe7668
    @leonardofillipe7668 4 ปีที่แล้ว +882

    Now I realized that the steps for recursive problem solving is basically the same steps taken in induction proofs in mathematics.

    • @HuyTran-ny7mg
      @HuyTran-ny7mg 4 ปีที่แล้ว +128

      That's why they're usually taught together in discrete math courses for computer science!

    • @angrymurloc7626
      @angrymurloc7626 3 ปีที่แล้ว +36

      There is a generalized version of induction called "structural induction" which has uses in proving things about recursively defined objects

    • @srujangurram
      @srujangurram 3 ปีที่แล้ว +7

      @@HuyTran-ny7mg yes I learnt that along with recursive functions in discrete math

    • @curiosdevcookie
      @curiosdevcookie 2 ปีที่แล้ว +2

      I’m stunned 😮

    • @_mrmark
      @_mrmark 2 ปีที่แล้ว +22

      Now I realized that I do not understand anything in either one or the other.😭

  • @igor-yc7ey
    @igor-yc7ey 3 ปีที่แล้ว +88

    Great explanation! Just a suggestion: highlight which line of the code is doing each step as you explain it

  • @markomozina7894
    @markomozina7894 4 ปีที่แล้ว +132

    I can’t even belive that the video of this quality has so few views. Keep up the good work!

  • @jonathanhirsch1717
    @jonathanhirsch1717 3 ปีที่แล้ว +68

    My jaw literally dropped when I saw that you had 32k subs, I was expecting over 500k!!! But now you're one sub closer!

  • @anujjadhav2175
    @anujjadhav2175 3 ปีที่แล้ว +161

    I am a simple person, I see recursion, I panic.

    • @user-sx5ib8vd6l
      @user-sx5ib8vd6l หลายเดือนก่อน +2

      I am a professional math lover. I see recursion, I panic.

    • @hasanmuttaqin464
      @hasanmuttaqin464 11 วันที่ผ่านมา

      solid answer

    • @hasanmuttaqin464
      @hasanmuttaqin464 11 วันที่ผ่านมา

      solid answer

  • @mohammedsanaullah1065
    @mohammedsanaullah1065 4 ปีที่แล้ว +123

    Im really glad that TH-cam finally recommended something that I really needed. Your passion for CS I really resonate with. Amazing video and unparalleled explanation. After encountering recursion, my interest in dynamic programming dwindled quite a lot, but your videos really helped me overcome this hurdle of mine. Many thanks, keep up the amazing work, Here's to hoping for more amazing content Cheers!

    • @Reducible
      @Reducible  4 ปีที่แล้ว +30

      Wow, that is one powerful comment Mohammad! Thanks for taking the time to write it and comments like yours mean a lot to me. I'm glad this video helped rekindle your interest in recursion and dynamic programming. Those are hard topics so there's no shame in admitting that they can be frustrating, and the goals of videos like this are to find a way past that frustration and focus on learning the beauty of the concepts, however hard that can be at times. I'm happy that you were able to see that through this video. I'm definitely planning on making future content, so stay tuned!

  • @pankajbisht897
    @pankajbisht897 3 ปีที่แล้ว +8

    the effort you put into explaining these complex concepts is unimaginable. I have never seen this kind of presentation for explaining an algorithm. Keep it up please.

  • @abhirup619
    @abhirup619 ปีที่แล้ว

    spent 2 hours last year trying to understand towers of hanoi without any context (just by lloking at code) ...finally gave up and now, after you explained the recursive approach I coded it in python in 10 minutes. just shows what a huge difference a systematic approach can make. your video helped me immensely. thank you

  • @souravsharma9505
    @souravsharma9505 2 ปีที่แล้ว +1

    Nobody could have explained it better..genius.The dominos concept is gold!

  • @puspamadak
    @puspamadak 3 ปีที่แล้ว +5

    I don't ever take the time to think of such hard problems. But your lessons gives me confidence. Thanks a lot!

  • @fairextl
    @fairextl 4 ปีที่แล้ว +3

    I was thinking about this problem a while back, today I got one of your videos recommended to me, and now I'm here! Astounding explanation!

  • @HalfEye79
    @HalfEye79 3 ปีที่แล้ว +43

    A few years ago, I solved the towers of hanoi with a loop.
    I assumed, that there are always three rods. And I said, that an empty rod is a very large disc.
    I only needed one input: the number of discs. I had realized quite another pattern, for which it is important, whether the number of discs is odd or even.
    The pattern is, that every other move is the move of the smallest disc. If the number of discs is odd, it always moves start -> end -> other -> start. If the number of discs is even, it always moves start -> other -> end -> start. The other move is always the smaller of the two discs on top of the bigger disc.
    This solution might might have a few memory issues, but it works.

    • @kadelchess42
      @kadelchess42 2 ปีที่แล้ว +1

      That is so interesting

    • @muhammadumarorakzai
      @muhammadumarorakzai ปีที่แล้ว +1

      that is how i solved it for my C lab problem. had to play it so many times to figure out that pattern

    • @yaglehoole5662
      @yaglehoole5662 วันที่ผ่านมา

      Solving it with a loop (and memory arrays) can even accommodate a larger N than the recursive-function approach can because you can bypass the stack-overflow ERR for large Ns. But you will get a D or F for your programming assignment in a CS class taught by a CMU/MIT/UC-Berkely-caliber prof, because you completely miss the point of the assignment, which is to test your grasp of *recursion*. You were being taught to conceptualize, to become a computer scientist/programmer/software engineer, not a day laborer hauling bricks with clever moves.

    • @yaglehoole5662
      @yaglehoole5662 วันที่ผ่านมา

      In the school I went to class assignments were graded by TAs only. I meant the TAs worth their salt would grade you D or F (for failing to write a recursive function) and the profs would back them up.

    • @HalfEye79
      @HalfEye79 23 ชั่วโมงที่ผ่านมา

      @@yaglehoole5662
      You are missing a point, not me. I'm no American, I wasn't on a university and it wasn't a test of my grasp of recursion.
      Why are you concluding from the towers of Hanoi, that it has to be in a recursive function? Would I then say that, when I failed miserably for that (as you assumed)?

  • @samuelsitina8558
    @samuelsitina8558 2 ปีที่แล้ว +1

    The simplicity of the code is truly beautiful.

  • @iszaffar
    @iszaffar 4 ปีที่แล้ว +19

    Thank you for taking the time and effort to make this video. The quality of the editing and animations in the video are excellent and remind me of 3Blue1Brown's videos. Great explanation and it really helped me to visualise and understand how this problem works!

    • @Reducible
      @Reducible  4 ปีที่แล้ว +7

      Thanks for the awesome comment! Glad this content helped you with this problem!

    • @alinac5512
      @alinac5512 3 ปีที่แล้ว

      Lol, I was thinking of 3blue1brown too.

    • @chriswu6823
      @chriswu6823 3 ปีที่แล้ว +1

      @@Reducible was that intro a reference to his ted talk hahaha

  • @arielcavalcante8187
    @arielcavalcante8187 3 ปีที่แล้ว +7

    after watching the code part (from 16:00 to 20:00) a couple of times and not understanding a single thing, I wrote the functions on paper and watched again and my mind blew away. Damn you're amazing.

  • @MUHAMMADASADSHAHAB
    @MUHAMMADASADSHAHAB ปีที่แล้ว

    Simply no words to praise this person! I often feel lazy for leaving comments on youtube videos, but this time I must. Kindly make a playlist for explaining the theory of all the data structures and algorithms.

  • @jocelynchang183
    @jocelynchang183 3 ปีที่แล้ว +5

    This video is soooo great! It took me awhile, but after repeating your video for 5 times, I finally understand this completely and was able to even work out examples with 5+ discs on my own. Thank you so much!!!

  • @SaumyaSharma007
    @SaumyaSharma007 4 ปีที่แล้ว +3

    Best Teacher Award goes to u Man.....
    Seriously best explanation I have ever seen 👌🔥🔥🔥🔥🔥

  • @williamrutherford553
    @williamrutherford553 4 ปีที่แล้ว +32

    Great video for introducing the puzzle! One piece of critique though, When you talked about the "recursive leap of faith" (the induction hypothesis) you took n-1 to mean the second to last domino. This can be a bit confusing. I think it's more explanatory if you just said: Pick any domino, and assume it will fall over. If it falls over, prove the next domino (+1) will ALSO fall over. Thus, the first domino falls because of the base case. The second domino falls down, because the first one falls. The third falls, because the second falls because the first, etc etc. That explanation is better at showing how a proof by Induction kind of "cascades" like dominoes, proving every case. Otherwise, it can seem a bit like assuming something random, just to come up with a result.

    • @Reducible
      @Reducible  4 ปีที่แล้ว +12

      Ah, that is a subtle and good point. Thanks for the feedback!

    • @sandeepverma-mp9co
      @sandeepverma-mp9co 2 ปีที่แล้ว +2

      Yes that was a bit confusing

  • @davidruiz2656
    @davidruiz2656 ปีที่แล้ว

    Thank you so much for this. No one has explained recursion as well as you did. I had a similar problem to this in one of my assignments: Find recursive function to solve a tower of hanoi for n discs if you want to move them from 1st peg to 3rd peg and you can only move discs to an adjacent peg. I was overwhelmed when I tried it on my own the first time but after watching your video I was able to figure out the solution for this modified version of the problem. Keep up the great work.

  • @zhangyi5145
    @zhangyi5145 3 ปีที่แล้ว +5

    It was my biggest challenge when I started my CS course. It's a wonderful presentation, what a great work!

  • @samgodse5824
    @samgodse5824 ปีที่แล้ว +1

    Greatest video ever on towers of hanoi problem. Even though I have tried to understand this problem number of time I finally understood it here. Because I was trying to name the discs as well but now I realised it isn't necessary since we'll always be moving top disc on a certain rod. Absolutely amazing way of explaining!! Keep it up!!🎉

  • @gautamkumarshukla3055
    @gautamkumarshukla3055 3 ปีที่แล้ว

    world's best video to show how tower of hanoi works recursively

  • @surfnerder
    @surfnerder 3 ปีที่แล้ว +1

    As always, fantastic video, thanks a lot!
    I'm certain you know about this and just didn't mention it to keep things organized and a little more intuitive but I'd like to point it out anyways for the fellow viewers who might be interested:
    You can simplify the code even further when having n = 0 as your base case. It sounds kind of useless at first but solving the problem with 0 discs just means “do nothing“ which allows you to save space in your code:
    def h( n, start, end):
    if n = 0:
    do nothing
    else:
    other = 6 - (start + end)
    h(n - 1, start, other)
    pm(start, end)
    h(n - 1, other, end)
    ...this boils down to:
    def h( n, start, end):
    if n > 0:
    other = 6 - (start + end)
    h(n - 1, start, other)
    pm(start, end)
    h(n - 1, other, end)

  • @jacksonwang3974
    @jacksonwang3974 4 ปีที่แล้ว +7

    This is the visual version of CS Bible. A ton of respect and appreciation

  • @rmatarrita
    @rmatarrita 2 ปีที่แล้ว +1

    I had solved this problem on my own before watching the video. Btw, in my personal case I found the iterative solution harder to come up with than the recursive one. Since I had already solved this problem before watching the video, what blew mi mind was the little arithmetic "hack" to find the "other" rod: 6 - (start + end) LOL. Great stuff!

  • @kamiosu
    @kamiosu ปีที่แล้ว +2

    5:30 was the moment of epiphany for me, thanks.

  • @DruthendraKommi
    @DruthendraKommi 9 หลายเดือนก่อน +1

    Video might be old but concept is like advance clear... 😊

  • @susantipsyhealy7655
    @susantipsyhealy7655 7 หลายเดือนก่อน

    I have never been good in math, even simple math. I have an app called IMPULSE. One of the games is Tower of Hanoi. It started out relatively simple but I was taking so long to finish each level and was ending up at 2% of the number of moves and time used.
    So i searched out a video to help me understand how this game works.
    I never thought it was a mathematical problem.
    One of my issues is my ADHD & ASD brain.
    Trying to keep organized in my thinking is not easy. But now I hope to finish my next level in much fewer moves. I will never reach a faster time, but improving in fewer moves is now my biggest goal.
    Thank you for this video

    • @neetusaxena7881
      @neetusaxena7881 2 หลายเดือนก่อน

      Don't worry bro u can get more better ❤❤

  • @tmorid3
    @tmorid3 3 ปีที่แล้ว +6

    This is actually an amazing video, with super clear and simple explanations and animations. This is absolutely amazing and mind blows.
    Thank you so much

  • @nikosrouskas2438
    @nikosrouskas2438 2 ปีที่แล้ว

    Amazing!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! I have been trying to solve this problem for a while now and I was so confused with other solutions on the internet (the code of the solutions) but yours is extremely intuitive and elegant. I am very new to recursion and you made this so understandable. THANKS! I hope you continue making such videos because you really really help the community!

  • @swapnilnagar4710
    @swapnilnagar4710 4 ปีที่แล้ว +5

    Mindblowing explanation and animation! That 'Dominos' concept :), I personally liked it!

    • @Reducible
      @Reducible  4 ปีที่แล้ว

      Thank you, I had a lot of fun making that domino animation so glad you appreciated it!

  • @Christobanistan
    @Christobanistan 3 ปีที่แล้ว +5

    Back in 1994, this was on of the first assignments in my "Algorithms and Analysis" course, the one and only course every single programmer needs to take. Then you learn some sorting algorithms, and bam, you 're a programmer. All the rest is just building more algorithms. Even learning programming languages are completely secondary.
    Most of the class got it wrong, but most had think on it for a few hours. And this was at a community college, so recursive algorithms are not that hard. Over the years, I've been surprised how easy they've become. It's the iterative, efficient approach that's harder!

  • @Joyddep
    @Joyddep 3 ปีที่แล้ว +1

    I finally understood this problem after I understood this problem

  • @arithmós_0x8
    @arithmós_0x8 3 ปีที่แล้ว +2

    Thank you so much for these awesome videos. I'm currently taking course MITx 6.00.1x over on edX and your videos are really helping me understand the concepts. Thank you again.

  • @akshaygiram
    @akshaygiram 2 ปีที่แล้ว

    Here's a small typo (speako) you might want to address. Thanks for such clear visualizations, you've been a great help.
    15:05 "solving hanoi for n-1 disks where the start ROD is the middle and the end ROD is the last ROD"

  • @umchoyka
    @umchoyka 3 ปีที่แล้ว +1

    Holy crap, that 3 step list gave me an "aha!" moment. Great video!

  • @Ayan-od8hk
    @Ayan-od8hk ปีที่แล้ว

    Best explanation ! I tried understanding this problem before but gave up, thankfully I found this video

  • @eriktruong9856
    @eriktruong9856 3 ปีที่แล้ว +51

    What is the reason for other = 6 - (start + end). There are 10 disks on the example? 14:02. If the first, second and third rod was labeled 1,2 and 3. Then the other rod is 6- (start+end). Is there a 4th rod? Edit: After som afterthought I think you possibly referring to the sum of tower numbers 1+2+3 = 6, but this wasn't explained deeply enough to be satisfying. So essentially this is a method of finding the auxiliary rod at any given time in the recursion.

    • @debjeet5715
      @debjeet5715 2 ปีที่แล้ว +5

      Your comment helped here. Thanks mate 🤜🏼

    • @quyenscc
      @quyenscc 2 ปีที่แล้ว +29

      We always have 3 rods: 1, 2 and 3. When start is 1, end is 2, then other is 6-(1+2) = 3. When start is 1, end is 3, then other is 6-(1+3) = 2. When start is 2, end is 3, then other is 6-(2+3) = 1, and so on. Thus, the formula makes sense.

    • @nikosrouskas2438
      @nikosrouskas2438 2 ปีที่แล้ว +3

      It was quite clear I think

    • @charlierock000
      @charlierock000 2 ปีที่แล้ว

      @@nikosrouskas2438 I think he though he had to add the number of disks in each rod

    • @ponyride23
      @ponyride23 10 หลายเดือนก่อน

      @@quyenscc Thank you! Our teacher taught us by naming the rods 'from', 'to' and 'other' and passing them as string parameters 'A', 'B', 'C'. The lesson was on divide and conquer though, not recursion, maybe that's why.

  • @arokumi5811
    @arokumi5811 2 หลายเดือนก่อน

    Dawg respectfully, I audibly came when I watch this. 10/10 you're goated

  • @tlqy
    @tlqy 3 ปีที่แล้ว +1

    You are the 3blue1brown of computer science. Keep it up!

  • @asmachapters
    @asmachapters หลายเดือนก่อน

    thank you so much you made it so easy and it seemed more logical, i spent one year thinking what possibly could that tiny code mean and now i get thanks to you!!!

  • @Flopsaurus
    @Flopsaurus 2 ปีที่แล้ว +2

    Black magic I tell you! That was crazy how a simple rule can solve a seemingly complex problem. I would have spent hours trying to intuit some complex solution to this.

  • @prayagcbose3862
    @prayagcbose3862 5 หลายเดือนก่อน

    Best explanation of TOH I've ever heard.

  • @mohd.salahuddinansari8008
    @mohd.salahuddinansari8008 3 ปีที่แล้ว +1

    This is the best explanation of tower of hanoi on TH-cam.
    So thanks a lot.

  • @sparrrooww5473
    @sparrrooww5473 9 หลายเดือนก่อน +2

    Very detailed and simple explanation. Keep up the good work

  • @hannahcora5939
    @hannahcora5939 3 ปีที่แล้ว

    oh my gawd after 30mins of trying to understand it from a book, i understood this algo in the first 5 mins watching your video!!!! THANKYOU

  • @bhautiksavaliya3635
    @bhautiksavaliya3635 4 ปีที่แล้ว +1

    The best explanation with the best visual animation. An extraordinary work.
    Thank you very much and please keep doing it.

  • @12jgy
    @12jgy 4 ปีที่แล้ว +4

    Love this! I just recently discovered this channel through the FFT video (TH-cam recommendations) and I just immediately loved it! The topics covered are really cool, and I really like the way they're presented in here (Reminds me of 3b1b, not only because Manin is used here to do the bulk of the animations, but too because of the quality of the explanations). Now, one neat little fact about this algorithm for solving the towers of Hanoi is that if you have n disks, this algorithm takes exactly 2^n - 1 steps to complete (The proof is just a simple induction argument for those who might want to try to figure it out), and in fact, if I'm recalling this correctly, this is actually the optimal amount of steps, you can't go any lower than this! Quite fascinating if you ask me.

    • @Reducible
      @Reducible  4 ปีที่แล้ว +3

      Thank you for this comment! I absolutely love compliments like this one!
      And yeah that's a fun inductive reasoning exercise -- fun fact by the way, you can see the number is steps is 2^n - 1 visually by generalizing the tree diagram for the recursion that we did here. In fact, I believe I touched upon this in the Big O notation video with the O(2^n) example. The basic idea is counting the number of nodes in a tree where at each level we have two branches representing calls to n - 1 and continue until we reach the base case of 1. The inductive argument you mentioned also works for solving this problem, but a fun visual addition.
      Thanks for sharing this!

  • @dvdpro3726
    @dvdpro3726 4 ปีที่แล้ว +4

    damn, this channel is so underrated. I came here after watching your 5 steps for solving recursive problems and I am blown away after seeing that whole thing took only 10 lines of code, that's amazing

  • @darasimiajewole007
    @darasimiajewole007 2 ปีที่แล้ว

    My mind is absolutely blown by this solution

  • @maheshvshet
    @maheshvshet 4 ปีที่แล้ว +10

    You amaze with awesome content. The explanation was some understandable, I can hardly forget it. Thanks.

  • @akhilgupta3664
    @akhilgupta3664 4 ปีที่แล้ว +2

    This video just explained it in easy manner..
    Using animations make things to understand easily...Carry on and keep on adding the videos of data structures and algorithms in your playlist ..😀
    Eagerly waiting for next video !!!
    Happy Learning !!

  • @kedardeshmukh1168
    @kedardeshmukh1168 ปีที่แล้ว

    This is the best video visualization of any CS concept i have erver seen....... Keep it up

  • @sherazdotnet
    @sherazdotnet 2 ปีที่แล้ว

    Best explanation to leap of faith concept in recursion hands down (time trac: 11:00). Absolutely amazig. Subscribed

  • @눈에눈이들어가니눈물
    @눈에눈이들어가니눈물 ปีที่แล้ว

    This is the video that explains the problem the best so far.

  • @alexkang7336
    @alexkang7336 4 ปีที่แล้ว +1

    These videos remind me of 3blue1brown's videos. Really appreciating your work! Thank you!

  • @lesleyeb
    @lesleyeb 3 ปีที่แล้ว

    Beautiful. You’re really talented at unraveling seemingly complex concepts very elegantly. After watching your videos, I can’t help but knowing the concepts matter-of-factly. And wonder to myself why I wasn’t able to get it earlier.

  • @AnantaAkash.Podder
    @AnantaAkash.Podder 6 หลายเดือนก่อน

    By Far the Best Explanation Ever for Recursion with Those Tips😀😀

  • @clemofunhound8381
    @clemofunhound8381 2 ปีที่แล้ว

    You saved my day! I am taking a course on discrete mathematics and this was a heck of an explanation!!!! Cheers!

  • @alphamega3306
    @alphamega3306 4 ปีที่แล้ว

    Excellent explanation. This recursive program definitely blew my mind when I first saw it two days ago. I hand-drew out the stack frames for a 3 disk problem. And even though it worked, I still couldn’t grasp HOW it was working-the abstract idea of n-1 recursively moving sequentially smaller stacks was the part the really got me. After watching this video a second time, it clicked. The crux of the program’s ability is in that assumption that n-1 will work. It’s pretty amazing stuff. Thank you!

  • @davedsp8513
    @davedsp8513 2 ปีที่แล้ว

    I remember this being a pancake themed recurring puzzle in a Professor Layton game when I was young. I didn't understand the whole recursive ramifications of it but I'm pretty proud I managed to figure out the general strategy of breaking it down to each smaller tower

  • @jayantverma6196
    @jayantverma6196 4 ปีที่แล้ว +4

    This was so awesome man, i watched all of your videos and they are amazing. Big fan here!!!!!

  • @bubblesort8760
    @bubblesort8760 2 ปีที่แล้ว

    the best videos that i have ever watched that explains Towers of Hanoi. I love this channel. Keep up the good work. I can't wait watching this kind of vids.

  • @ialgorithms
    @ialgorithms ปีที่แล้ว

    Thank you so much. I was using n,A,B,C initially which was bit difficult but after watching your video it make more sense now.
    i.e. n, source, temp, dest as n, A,B,C

  • @harikrishnan204
    @harikrishnan204 4 ปีที่แล้ว +1

    the explanation is amazing! I hope you make more videos on more algorithmic problems. there are very few on youtube who explain with such clarity

  • @rajat0610
    @rajat0610 ปีที่แล้ว

    woooooooooooooooooooooooooooooooooowww!!
    this was wonderful!
    the only explanation of this problem that made sense
    i tried searching all over and failed to get a good explanation of the problem and underlying concepts and this video covers all of it
    Grant Sanderson would be proud :)

  • @voidproc
    @voidproc ปีที่แล้ว

    Honestly great job dude
    You have much respect from me
    I havent seen anyone having such a great ability making something so complex , look so easy

  • @aminmaleki4592
    @aminmaleki4592 7 หลายเดือนก่อน

    Best explanation to Hanoi tower and its basis in discrete mathematics and algorithms, This is multi target video!!

  • @yashkalyan
    @yashkalyan 2 ปีที่แล้ว

    if there is oscar for teaching it should go to this video,great explaination.

  • @amitabhsahoo4082
    @amitabhsahoo4082 3 ปีที่แล้ว

    God bless for such a beautiful explanation and Saving me from the sleepless night of not understanding the solution 🙏

  • @ershadulrayhan7324
    @ershadulrayhan7324 4 ปีที่แล้ว

    Thank you very much for this video. You have not only explained the problem easily but also introduced us to a framework to solve recursive problems. 👍

    • @Reducible
      @Reducible  4 ปีที่แล้ว +1

      Thanks for the kind comment! Glad to hear that this content helped you!

  • @alexmattyou
    @alexmattyou ปีที่แล้ว

    Woooow, this is mind blowing. I'll try to understand this again. Thanks for making it visual, I can undertake something

  • @dacfniel5442
    @dacfniel5442 4 ปีที่แล้ว +1

    Bless you, man. The best explanation on TH-cam.

  • @crjacinro
    @crjacinro 3 ปีที่แล้ว +1

    More contents please! Would like to see some visual explaination on other problems in DSA. Maybe some hard problems on leetcode or google interview questions.

  • @praphulyadav4471
    @praphulyadav4471 2 ปีที่แล้ว

    thank you very much i never thought this problem will be so simple to understand. you made this hard problem very simple

  • @surabhigupta49
    @surabhigupta49 ปีที่แล้ว

    Thank you so much. This is by far the best explanation on youtube for this problem. Thoroughly understood the logic because of the amazing animation.

  • @loganbrown9553
    @loganbrown9553 2 ปีที่แล้ว

    I was thinking about how to solve this before watching the video and I thought of a really nice and elegant way to think about it:
    You can easily move 2 elements from one side to the other by moving the top element out of the way, moving the bottom element to the destination and then putting the top one back on.
    This means that you can move two elements as if they were a single element as long as nothing smaller is below them.
    Since you can now move 2 elements as one you can effectively convert a 3 stack to a 2 stack by treating the top 2 elements as a single element.
    Now that the 3 stack can be moved as a 2 stack the above algorithm can be used to move it as if it were a one stack.
    This strategy can then be repeated indefinitely for any height of tower

    • @loganbrown9553
      @loganbrown9553 2 ปีที่แล้ว

      Note: this can be implemented recursively by making a move stack function that moves a spesified number of elements from the top of a stack to another rod that executes the move 2 strategy but when moving the top ring calls itself with one less specified element unless only one element is being moved in which case it directly moves the element.

  • @bidish2224
    @bidish2224 2 ปีที่แล้ว

    The set of steps used for moving (n-1) tower of Hanoi from rod 1 to rod 2, if used in reverse order then the (n-1) tower of Hanoi returns to rod 1 from rod 2. In all cases all types of rings can be placed on the lowemost biggest ring as all other rings will be smaller than it and hence can be ignored while solving (n-1) tower of Hanoi. This thing was very beautiful 🤯🤯🤯

  • @fangle0121
    @fangle0121 4 ปีที่แล้ว +5

    Thank you so much! The animations are amazing to aid our understanding of this problem. :)

    • @Reducible
      @Reducible  4 ปีที่แล้ว +2

      Thank you for the kind comment and I'm glad the animations were able to help with your understanding!

  • @rashidyaseen6270
    @rashidyaseen6270 ปีที่แล้ว

    best explanation available on internet

  • @wilson6c
    @wilson6c 3 ปีที่แล้ว

    love it so much, you beat all those MIT lecturers

  • @devalt1
    @devalt1 3 ปีที่แล้ว

    Struggling CS student here. Really great video!

  • @noorfathima3499
    @noorfathima3499 3 ปีที่แล้ว

    This is the best explanation I have come across till date!! and nothing can be better than this.. thank you

  • @sickdarth
    @sickdarth 4 ปีที่แล้ว

    Subscribed. Who tf won't want more videos like this?!

  • @Luingus
    @Luingus 2 ปีที่แล้ว

    Basically the function is f(n)=2f(n-1)+1, where the recursion is basically in solving the previous tower twice, once for the middle, and once for the end, and we add the plus one for the final disk.

  • @bornmad
    @bornmad 3 ปีที่แล้ว

    While looking at the steps for solving recursive problem , I remembered my "principle of mathematical induction" class back in school

  • @vsk0208
    @vsk0208 3 ปีที่แล้ว

    Best explanation I have seen on TH-cam, I appreciate your effort. Thanks for uploading this video :)

  • @jonathanpopham5483
    @jonathanpopham5483 2 ปีที่แล้ว

    Don't need a "leap of faith" if you prove the n+1 case, this is the principle of mathematical induction.
    If n is a natural number (n >= 1 in CS terms), and the function holds in the basis case (n=1, the smallest value for which the statement is true), then it is necessary to prove the n+1 case. It is convention in mathematics to assign n = k+1, where k is a natural number that fulfills the base case. If we show that k+1 holds, then that means that we can recursively plug k+1 into k to say that n = (k+1) +1. This process can be repeated for all natural numbers, hence by the principle of mathematical induction the statement is true for all natural numbers.
    There are no leaps of faith in mathematics.
    Good video, nice animations.

  • @raht9578
    @raht9578 3 ปีที่แล้ว +1

    this video is an 11/10 effort

  • @thachkiencao3883
    @thachkiencao3883 3 ปีที่แล้ว

    The thing is i subscribe to your channel in my first arrival to the channel after seeing this video
    I dont often do that to other channels
    Keep goodjob!

  • @Saikiran-pf1ry
    @Saikiran-pf1ry 3 ปีที่แล้ว

    You need more views! Excellent explanation. Nothing can beat the Aha moment when you actually understand how something works! Thanks a ton

  • @astropgn
    @astropgn 2 ปีที่แล้ว

    When I was learning principles of programming, this was of course one of the assignments. The course I was doing taught it by directing us to the answer. The way they did it was to break the problem into smaller steps, explain each step without giving the answer and providing tests to see if our attempt were correct after each step.
    So for this problem they did this and I was getting the steps right after some thinking. And when I got to the very end, I had every piece working, and I just had to put everything together. I did it and it worked. I solved a giant hanoi tower... And the craziest thing was: I still don't understand how lol

  • @mariiatverdokhlib2057
    @mariiatverdokhlib2057 ปีที่แล้ว

    Your work brought a lot of insights into solving recursive tasks, thanks!

  • @MdOwaisUmar
    @MdOwaisUmar 3 ปีที่แล้ว

    There was a smile on my face seeing the solution
    🙂

  • @vinwizard1217
    @vinwizard1217 2 ปีที่แล้ว

    Such a beautifully visualised video that I was able to code it within minutes of seeing it. Thank you so much

  • @lakshyamangal51
    @lakshyamangal51 3 ปีที่แล้ว

    thank you so much man ❤️ please keep making videos like this 🙏the quality and simplicity you have is unmatched.

  • @alkamishra9974
    @alkamishra9974 3 ปีที่แล้ว

    Great video. Only watched a couple of videos of tours but can tell your love for the subject.