Solved Recurrence - Iterative Substitution (Plug-and-chug) Method

Sdílet
Vložit
  • čas přidán 13. 10. 2016
  • This is an example of the Iterative Substitution Method for solving recurrences. Also known sometimes as backward substitution method or the iterative method.
    An example of solving the same recurrence using the Tree method can be found here: • Solved Recurrence Tree...
    Note that there is another method of solving recurrences that is unfortunately called the substitution method by the CLRS Algorithms Book that many R1 instructors use to teach algorithms. This other method is not a little bit like the iterative substitution method used here. It is more accurately called the "guess-and-check" method, since you make a guess about what the runtime is and then prove it by induction.
    In a quick survey of the Algorithms textbooks near at hand, CLRS and Klienberg & Tardos call the "guess-and-check" method "substitution" while the books by Neapolitan and by Levin, call what I did the substitution method. Leafing through Rosen it appears to only show the substitution method, but it doesn't name it. Epp's book calls this method the iterated method and does not teach the other method.
    The bottom line is that in mathematics it is often the case that a single name is used to refer to multiple things and sometimes a single thing may have multiple names. Even in the same subfield. It's important to remember this and that it's not the name that matters.

Komentáře • 259

  • @Bonzo632
    @Bonzo632 Před 5 měsíci +26

    You are the hero in the night. The dancing of the flowers in the wind. The moonlight dipping into the sand. Thank you John. On all my next exams, I will write “This one’s for John.” before all recurrence relations.

  • @Shefetoful
    @Shefetoful Před 5 lety +293

    Learned more in 10 minutes, than in the 2 lectures covering this, thanks.

    • @thetomatoes7075
      @thetomatoes7075 Před 4 lety +8

      They did 2 lectures to cover just this ??

    • @charulatha.p2782
      @charulatha.p2782 Před 3 lety

      Exactly 😂

    • @danielgilder8672
      @danielgilder8672 Před 2 lety

      Literally same here, only had 2 lectures

    • @WarmHugSeeker
      @WarmHugSeeker Před rokem +1

      True LOL. Glad I found this treasure.

    • @allissahertz1769
      @allissahertz1769 Před 9 měsíci

      I came here to say exactly this. Two full lectures covering this and I still was confused, and this one video and I finally get it.

  • @alanbiju1765
    @alanbiju1765 Před rokem +34

    It's been 6 years and this still remains one of the best videos on this topic.

  • @electricwatches1
    @electricwatches1 Před 5 lety +18

    I learned something in 9 minutes that I couldn't learn in 3 hours while in class. Thank god people like you exist!

  • @bigboykazmi
    @bigboykazmi Před měsícem

    In case you were wondering, this is still super helpful to people (at least, me!) 7 years later. Thanks.

  • @gerritgerritsen2113
    @gerritgerritsen2113 Před 7 lety +84

    This was really helpful. For some reason the most intuitive substitution method video I've seen. Thanks a ton.

  • @AiSeii
    @AiSeii Před 2 lety +6

    Out of all the videos I have watched trying to help me solve recurrences, yours has been the most helpful one and has finally helped me figure out what everything means. Thank you for explaining every step and where you got everything. Thank you so so much.

  • @fuudonanma1411
    @fuudonanma1411 Před 7 lety +5

    I was absent my algo class of recursive algorithm / solving recurrence, and your video helped me from suffering the pain of solving recurrence problems, perfectly. Thank you for you detailed explanation and step to step tutorial.

  • @jesusalejandrorodriguezgar2735
    @jesusalejandrorodriguezgar2735 Před 11 měsíci +1

    What my teacher could not explain in 8 hours, you did under 10 min. Thank you so much

  • @halfnorth
    @halfnorth Před 3 měsíci

    I know you uploaded this seven years ago but from all the different videos on explaining this method, you're the one that did it in a clear way that I can actually understand. Thank you.

  • @luizlencioni6340
    @luizlencioni6340 Před 4 lety +3

    The best video I've ever seen about solving recurrences. Thank you.

  • @bh_umbc
    @bh_umbc Před 7 lety +1

    Very well done. Going through the 3rd step was a good call as well. Basically, the other videos on this topic are a bit too theoretical or obscure. This iterative way of performing the method is much easier to follow. Thank you!

  • @hydrophobicwalrus749
    @hydrophobicwalrus749 Před 4 lety +11

    Much more straightforward than my professor makes it out to be.

  • @ToasTeR1094
    @ToasTeR1094 Před rokem

    You're a savior, This is so clear and concise, wish my professor had explained it like this. Thank you!

  • @sherazbutt6012
    @sherazbutt6012 Před 3 měsíci

    I have watched many videos about this topic but your explanation is outstanding

  • @CaptainJellyBS
    @CaptainJellyBS Před 7 lety +78

    Can I just have you as my algorithms professor?

    • @johnbowers5447
      @johnbowers5447  Před 7 lety +37

      Yes, you can! Come to James Madison University =D, we've got lots of great CS Profs!

  • @mundapakistani
    @mundapakistani Před 6 lety +1

    How I was struggling with this concept but you made it so simple. I Salute you Sire.

  • @contrafoz
    @contrafoz Před 5 lety +1

    This video was great and was the one that helped it all finally click for me. It was essential that this example had an n outside of the T(n/2) so I could see how that was handled. Now I'm struggling to solve a recurrence that is divided into different sized sub-problems (ie: T(n)=T(n/2)+T(n/4)+T(n/8)+n, where T(1)=1) using substitution and am wishing I had another video of yours as reference.

  • @MorganAriel
    @MorganAriel Před 7 lety +37

    This is probably the BEST recurrence relation video I've seen, thank you so much!

  • @GreeeenT
    @GreeeenT Před 6 lety

    I'm so glad I found your videos before my quiz tomorrow. Thank you !

  • @sirxavior1583
    @sirxavior1583 Před 3 lety

    This has got to be one of the best explanations. The only step that's missing which is beyond the scope of this video is the induction proof at the end to show that T(n) = O(n log n) for all n>1.

  • @ashwanivarshney9406
    @ashwanivarshney9406 Před 7 lety +1

    It is really helpful
    Thanks john
    I have exam day after tomorrow but I even don't know the methods of solving recurrence it is really helpful ,simple to understand and remember

  • @dilaragoral2259
    @dilaragoral2259 Před 5 lety +4

    I was looking for this solution for hours in the other sites. You have the best (and the most detailed) style of explanation. I really don't know how can I thank you. Shared with friends. And THANKS A LOT!!

  • @thetomatoes7075
    @thetomatoes7075 Před 4 lety +2

    You teach better than the Algo teacher at ETH. Great job!

  • @Jindujun
    @Jindujun Před 4 lety +2

    Best explanation on CZcams, you just saved my day, Sir.

  • @MrAbbasalrassam
    @MrAbbasalrassam Před 5 lety +2

    You are amazing ! I was stuck more than 3 days ! now got it . thank you

  • @redacted6673
    @redacted6673 Před 7 měsíci

    ohh my gawddd this video ........i was searching for a video that broke this process down and finally i got it thank you good sir

  • @davekaushik4863
    @davekaushik4863 Před 2 lety

    Thank you for the helpful video! I appreciate the step by step process especially since math isn't the strongest subject I have. Thank you sir!

  • @moisascholar
    @moisascholar Před 6 lety +1

    Great explanation and algorithm to go about solving these pesky recurrence relations! Many thanks.

  • @kedarnadkarny4718
    @kedarnadkarny4718 Před 7 lety +1

    Very clear. Good job John!

  • @olivia0909
    @olivia0909 Před 5 měsíci

    With this video, solving recurrence by substitution is tick. Thanks for the video although its like more that 5 years since the upload, it is still helpful.

  • @SuperRashadWilliams
    @SuperRashadWilliams Před 4 lety

    This so much better our teacher makes us guess big o then from there we work through to find the asymptomatic notation

  • @fahdfayed1825
    @fahdfayed1825 Před 3 lety +1

    First comment of my 10 years on youtube. Thank god for your existence.

  • @TheChug00
    @TheChug00 Před 6 lety +1

    Best video. Super clear explanation! Great job

  • @FarazKhan-xd4bd
    @FarazKhan-xd4bd Před 7 lety

    Thankyou man. Best explanation till now i've seen.

  • @bh3302
    @bh3302 Před 4 měsíci

    Dude, you are awesome. Thank you so much for how you explain each step.

  • @alvinkatojr
    @alvinkatojr Před 4 lety

    So simply, fluid and clear. John Bowers for president!

  • @karamveeryadav8824
    @karamveeryadav8824 Před 11 měsíci

    thanks a lot brother for this amazing 9 minutes tutorial

  • @rahulkher8207
    @rahulkher8207 Před 4 lety +40

    I'll be honest, I was NOT expecting the O(n log n) bomb at the end.

    • @Amy-tw3zh
      @Amy-tw3zh Před 4 lety +1

      Just use limits to verify. Limit as n goes to infinity for (4n+4nlog_2 n) / (n log_2 n) , which = 4 , which means it is O(n log_2 n indeed)

    • @Twannnn01
      @Twannnn01 Před 4 lety

      @@Amy-tw3zh Hi, can you further clarify how you can relate 4 to O(n*log_2(n))? I understood everything up until 4n+4n*log_2(n).

    • @lasseskaalum6258
      @lasseskaalum6258 Před 4 lety +1

      @@Twannnn01 You need to compare all the joints of the expression asymptotically. It's a little hard to explain, if you don't know what it means already. But basically, it means what @Mandey just said: To compare the values, when n is infinitely high. Take a look at the graph on this page to see if you can get the picture: www.bigocheatsheet.com/

    • @johnbowers5447
      @johnbowers5447  Před 4 lety +4

      That O(n log n) thing is sneaky. Can't turn your back for a second or it'll get you.

  • @hakancemgercek
    @hakancemgercek Před 3 lety

    Thanks to you I have learned what I need to learn, finally.

  • @phillip3m
    @phillip3m Před 5 lety +1

    Very well done. Thank you John!

  • @sareenabaig8751
    @sareenabaig8751 Před 5 měsíci

    7 years later... thank you!!!

  • @tahamagdy4932
    @tahamagdy4932 Před 7 lety

    Best 9 mins of Substituting

  • @MrGeorgerocker
    @MrGeorgerocker Před 5 lety +2

    Omg the first explanation ive understood thank you so much!

  • @gunaygultekin
    @gunaygultekin Před 7 lety +1

    perfect explanation, clear to understand

  • @geogaddi84
    @geogaddi84 Před 2 lety

    very well done. This is what youtube is all about for me.

  • @qR7pK9sJ2t
    @qR7pK9sJ2t Před 5 lety +2

    Extraordinary....Thank u Sir..Love from India
    #WeIndiaWeWin

  • @bryanarmijos5159
    @bryanarmijos5159 Před 5 lety

    BEST VIDEO HANDS DOWN. Subbed!

  • @chrisogonas
    @chrisogonas Před 3 lety

    That was elegant and very clear. Thanks

  • @user-mo1gh2kg9q
    @user-mo1gh2kg9q Před 5 lety +1

    This helped me big time for preparing the mid term. Thanks!

    • @mse312
      @mse312 Před 5 lety +1

      same , I have my midterm next week

  • @salmaabobakr1406
    @salmaabobakr1406 Před 5 lety

    Excellent.. it's the best one in recursion videos

  • @kanelindsay4995
    @kanelindsay4995 Před 3 lety

    Very good practical example compared to the bad slideshow video lecture version offered at my university.

  • @alphaomega657
    @alphaomega657 Před 4 lety +4

    My question becomes now: do we need to inductively prove for this? most books have an induction proof for solution, but they follow a "guess the big-O" before starting to do the math!

  • @asadmehmood408
    @asadmehmood408 Před 6 lety

    This was helpful please upload more examples to solved recurance...

  • @luisbremer9351
    @luisbremer9351 Před rokem

    this video is a gem!

  • @jakobhansen9688
    @jakobhansen9688 Před 4 lety +1

    Thank you very much, you are great at explaining

  • @zoe7886
    @zoe7886 Před 3 lety

    you, my friend, are a SAINT thank you

  • @darshilshah3941
    @darshilshah3941 Před 7 lety

    Great work man, keep it up. THanks a ton!!

  • @dinklemuffin8132
    @dinklemuffin8132 Před rokem

    This video was very helpful. Thank you

  • @tanvirwaseer16
    @tanvirwaseer16 Před 4 měsíci

    The most intuitive way I think this one is.

  • @jeroen3648
    @jeroen3648 Před 3 lety

    Thank you for this video , it helped me to solve recurrence relations

  • @derekliu8867
    @derekliu8867 Před 3 lety

    yep, this is the best vid on repeated sub hands down

  • @Stevofolife
    @Stevofolife Před 4 lety

    best example so far!

  • @adolfocarrillo248
    @adolfocarrillo248 Před 8 měsíci

    Thanks for sharing your knowledge, I got it.🎉

  • @yazidhanniche1064
    @yazidhanniche1064 Před 3 lety +1

    thank you , you saved my life

  • @turi104
    @turi104 Před 4 lety

    good explanation. made this method very clear.thankyou

  • @harshithakeerti
    @harshithakeerti Před 5 lety

    Which method is best iterative or guessing and induction method??

  • @tejaskashyap1392
    @tejaskashyap1392 Před 6 lety

    Great video! Saved me on my final!

  • @weilingwu9283
    @weilingwu9283 Před 2 lety

    Hi, how do you get O(n log n) in the last step

  • @BZ-du8nk
    @BZ-du8nk Před 8 měsíci

    At 3:40 when the 2's cancel, I don't understand why its still 2^2 if we used one of the twos to cancel out denominator and get 4n. I am confused. Can someone explain?

  • @perrym8048
    @perrym8048 Před 4 lety +1

    Why do the 2s cancel out at 3:46 ??

  • @deanbeebe74
    @deanbeebe74 Před 3 lety +1

    Seriously helpful - thank you so much!

  • @Utopus11
    @Utopus11 Před 5 lety +1

    Thank you, helped me a lot!

  • @mod_123_
    @mod_123_ Před 4 lety +1

    you just saved my life, thank you

  • @knanzeynalov7133
    @knanzeynalov7133 Před rokem

    It's been 7 years and it still the best video on the CZcams. Thanks for help!

  • @sayonpalit6390
    @sayonpalit6390 Před 6 lety

    I don't understand why its not n^2logn ,as we have 4n+4nlogn.Can someone explain?

  • @dillario4697
    @dillario4697 Před 3 lety

    Do you know how we would approach Fibonacci recurrences? As in, an equation of the form
    T(n) = T(n-1) - T(n-2) using the same method?
    When performing the recursive substitution (as the first step) would you plug (n-1) into into the T(n) then take that value (here you calculated it on the "expand scatch" side) and plug it back into the equation (on the "build solution" side) for T(n-1) leaving the T(n-2) as part of the 'new' equation.
    Or do we plug both (n-1) then (n-2), from T(n-1) and T(n-2) into T(n), as the first step, and expand on both?

  • @asmodius666
    @asmodius666 Před 4 lety

    Can anyone please explain me why he multiplied both sides by 2^i?

  • @superwendel
    @superwendel Před 5 lety

    Thanks a lot ! Very simple and useful !!

  • @sushanthapa1498
    @sushanthapa1498 Před 5 lety

    We do this as Iteration method. If question is asked to do by substitution method, can we do it? Whats the similarity?

  • @hotchocolate123
    @hotchocolate123 Před 2 lety

    great explanation ! thanks a lot

  • @noamansaleem3755
    @noamansaleem3755 Před 6 lety

    Awesome Bestest Video on Sbstitution Method

  • @fpsgod7259
    @fpsgod7259 Před rokem

    what if i have a case distinction between even uneven

  • @m.alaiady3627
    @m.alaiady3627 Před 3 lety

    when a = b it will be easy but what if a > b
    how i can solve this ?

  • @hgd2394
    @hgd2394 Před 4 lety +1

    thanks for this super helpful video! my professor was nowhere close to being this thorough!

  • @AuraRazor
    @AuraRazor Před 3 lety

    this was very helpful, thanks

  • @deveshsingh1479
    @deveshsingh1479 Před 8 měsíci

    beautifully done

  • @laibasattarkhan7547
    @laibasattarkhan7547 Před 10 měsíci

    I don't understand the last step that how directly you write the time complexity

  • @jakebush8941
    @jakebush8941 Před 3 lety

    Where did the T(1)=4 come from?

  • @TinieblaOscura
    @TinieblaOscura Před 4 lety

    You are the real MVP

  • @sharonthequeen28
    @sharonthequeen28 Před 2 měsíci

    How did you know what to substitute?

  • @erob7219
    @erob7219 Před 2 lety

    How would this work if their is no base case

  • @clovisgu57
    @clovisgu57 Před 6 lety +1

    crystal clear! thank you!

  • @robertsedgewick1266
    @robertsedgewick1266 Před 3 lety

    This video is a gem. This is how to teach!

  • @datim8540
    @datim8540 Před rokem

    Insane video🙏🏻

  • @MrAlbashiri
    @MrAlbashiri Před 6 lety

    you are the best. thank you very much for the amazing video

  • @omkarwarade1455
    @omkarwarade1455 Před 6 lety

    Sir can you upload a course algorithm analysis from scratch?

  • @krishnarathod6389
    @krishnarathod6389 Před 7 lety

    Thank you..It is helpful...keep uploading

  • @hemihobo
    @hemihobo Před 7 lety

    Great walk through thank you

  • @Azanali-kq5uy
    @Azanali-kq5uy Před 7 lety +1

    Really I understand very well