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

Поділитися
Вставка
  • Опубліковано 5 жов 2024
  • 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.

КОМЕНТАРІ • 262

  • @Bonzo632
    @Bonzo632 7 місяців тому +51

    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.

  • @Joel2Million
    @Joel2Million 5 років тому +311

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

    • @thetomatoes7075
      @thetomatoes7075 4 роки тому +10

      They did 2 lectures to cover just this ??

    • @charulatha.p2782
      @charulatha.p2782 3 роки тому

      Exactly 😂

    • @danielgilder8672
      @danielgilder8672 2 роки тому

      Literally same here, only had 2 lectures

    • @WarmHugSeeker
      @WarmHugSeeker Рік тому +1

      True LOL. Glad I found this treasure.

    • @allissahertz1769
      @allissahertz1769 11 місяців тому

      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 2 роки тому +35

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

  • @gerritgerritsen2113
    @gerritgerritsen2113 8 років тому +85

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

    • @johnbowers5447
      @johnbowers5447  8 років тому +5

      Thanks! Glad you got something out of it.

  • @electricwatches1
    @electricwatches1 6 років тому +19

    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 3 місяці тому +2

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

  • @AiSeii
    @AiSeii 2 роки тому +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.

  • @CaptainJellyBS
    @CaptainJellyBS 7 років тому +79

    Can I just have you as my algorithms professor?

    • @johnbowers5447
      @johnbowers5447  7 років тому +37

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

  • @MorganAriel
    @MorganAriel 7 років тому +38

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

  • @fuudonanma1411
    @fuudonanma1411 7 років тому +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

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

  • @Jindujun
    @Jindujun 4 роки тому +3

    Best explanation on UA-cam, you just saved my day, Sir.

  • @hydrophobicwalrus749
    @hydrophobicwalrus749 5 років тому +11

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

  • @halfnorth
    @halfnorth 5 місяців тому

    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 4 роки тому +3

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

  • @techenthusiastt9
    @techenthusiastt9 17 днів тому +1

    You saved my CGPA, John. Thanks a bunch!

  • @rahulkher8207
    @rahulkher8207 4 роки тому +41

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

    • @Amy-tw3zh
      @Amy-tw3zh 4 роки тому +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 4 роки тому +1

      @@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 4 роки тому +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  4 роки тому +4

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

  • @sherazbutt6012
    @sherazbutt6012 5 місяців тому

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

  • @sirxavior1583
    @sirxavior1583 4 роки тому

    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.

  • @thetomatoes7075
    @thetomatoes7075 4 роки тому +2

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

  • @ashwanivarshney9406
    @ashwanivarshney9406 7 років тому +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

  • @contrafoz
    @contrafoz 6 років тому +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.

  • @dilaragoral2259
    @dilaragoral2259 5 років тому +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!!

  • @ToasTeR1094
    @ToasTeR1094 Рік тому

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

  • @MrAbbasalrassam
    @MrAbbasalrassam 5 років тому +2

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

  • @fahdfayed1825
    @fahdfayed1825 3 роки тому +1

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

  • @SuperRashadWilliams
    @SuperRashadWilliams 5 років тому

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

  • @knanzeynalov7133
    @knanzeynalov7133 Рік тому

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

  • @olivia0909
    @olivia0909 7 місяців тому

    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.

  • @bh_umbc
    @bh_umbc 7 років тому +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!

  • @alvinkatojr
    @alvinkatojr 4 роки тому

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

  • @sareenabaig8751
    @sareenabaig8751 8 місяців тому

    7 years later... thank you!!!

  • @redacted6673
    @redacted6673 10 місяців тому

    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

  • @GreeeenT
    @GreeeenT 6 років тому

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

  • @hakancemgercek
    @hakancemgercek 3 роки тому

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

  • @bh3302
    @bh3302 7 місяців тому

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

  • @moisascholar
    @moisascholar 6 років тому +1

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

  • @gunaygultekin
    @gunaygultekin 7 років тому +1

    perfect explanation, clear to understand

  • @김창성-x2y
    @김창성-x2y 6 років тому +1

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

    • @mse312
      @mse312 6 років тому +1

      same , I have my midterm next week

  • @hgd2394
    @hgd2394 4 роки тому +1

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

  • @davekaushik4863
    @davekaushik4863 2 роки тому

    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!

  • @kedarnadkarny4718
    @kedarnadkarny4718 7 років тому +1

    Very clear. Good job John!

  • @karamveeryadav8824
    @karamveeryadav8824 Рік тому

    thanks a lot brother for this amazing 9 minutes tutorial

  • @qR7pK9sJ2t
    @qR7pK9sJ2t 5 років тому +2

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

  • @jakobhansen9688
    @jakobhansen9688 4 роки тому +1

    Thank you very much, you are great at explaining

  • @mod_123_
    @mod_123_ 4 роки тому +1

    you just saved my life, thank you

  • @kanelindsay4995
    @kanelindsay4995 3 роки тому

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

  • @geogaddi84
    @geogaddi84 2 роки тому

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

  • @TheChug00
    @TheChug00 6 років тому +1

    Best video. Super clear explanation! Great job

  • @deanbeebe74
    @deanbeebe74 3 роки тому +1

    Seriously helpful - thank you so much!

  • @MrGeorgerocker
    @MrGeorgerocker 5 років тому +2

    Omg the first explanation ive understood thank you so much!

  • @tanvirwaseer16
    @tanvirwaseer16 6 місяців тому

    The most intuitive way I think this one is.

  • @FarazKhan-xd4bd
    @FarazKhan-xd4bd 7 років тому

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

  • @alphaomega657
    @alphaomega657 4 роки тому +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!

  • @yazidhanniche1064
    @yazidhanniche1064 3 роки тому +1

    thank you , you saved my life

  • @zoe7886
    @zoe7886 3 роки тому

    you, my friend, are a SAINT thank you

  • @derekliu8867
    @derekliu8867 3 роки тому

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

  • @chrisogonas
    @chrisogonas 3 роки тому

    That was elegant and very clear. Thanks

  • @robertsedgewick1266
    @robertsedgewick1266 4 роки тому

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

  • @tahamagdy4932
    @tahamagdy4932 7 років тому

    Best 9 mins of Substituting

  • @asadmehmood408
    @asadmehmood408 6 років тому

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

  • @luisbremer9351
    @luisbremer9351 Рік тому

    this video is a gem!

  • @phillip3m
    @phillip3m 5 років тому +1

    Very well done. Thank you John!

  • @Stevofolife
    @Stevofolife 5 років тому

    best example so far!

  • @vinaytanwar7840
    @vinaytanwar7840 4 роки тому +1

    One thing i learned today.. always do research if you dont understand something in paid lectures

  • @jeroen3648
    @jeroen3648 3 роки тому

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

  • @salmaabobakr1406
    @salmaabobakr1406 5 років тому

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

  • @ahmari7711
    @ahmari7711 4 роки тому

    Thank you so much, can you please collect the videos of algorithm under one playlist 🙏🏻

  • @TinieblaOscura
    @TinieblaOscura 4 роки тому

    You are the real MVP

  • @dinklemuffin8132
    @dinklemuffin8132 Рік тому

    This video was very helpful. Thank you

  • @sachinkarn3057
    @sachinkarn3057 4 роки тому

    I think you should make more videos over this topic sir and thank you

  • @turi104
    @turi104 4 роки тому

    good explanation. made this method very clear.thankyou

  • @atlasmaxima1418
    @atlasmaxima1418 7 років тому

    Thank you so much for explaining it step-by-step! I was so lost in class today with the substitution method; But this video has made it more clear! Where do you get T(1) = 4 ? Do we make these up ?

    • @johnbowers5447
      @johnbowers5447  7 років тому

      You do not make up the base case, it should be given as part of the problem. If the problem was T(1) = 7, for instance, the final evaluation would be different.

  • @prateeksenapati2152
    @prateeksenapati2152 5 років тому +1

    Hey, John! You are amazing 🔥 I wonder why you stopped making videos....

  • @babbintandukar9959
    @babbintandukar9959 7 років тому +44

    its iterative method not substitution

    • @johnbowers5447
      @johnbowers5447  7 років тому +25

      Yes, the full name is the "iterative substitution method", which some people call shortly the iterative method whereas others call it the substitution method. This is a bit confusing, because there is also a guess-and-prove method that is sometimes called the "substitution method" as well. It depends on where you learned it what you call it. This is a common problem in mathematics. We've way overloaded a lot of mathematical terms (ever search for Cauchy's Theorem? I know of at least 3 different theorems in different areas of mathematics called Cauchy's Theorem in that field).

    • @babbintandukar9959
      @babbintandukar9959 7 років тому

      umm i see so we do iterative method anf find tiome complexity then use it for substitution method..bro i needed that 2nd part 1

    • @johnbowers5447
      @johnbowers5447  7 років тому +7

      No, this analysis above let's you get the closed form exactly. No need for a proof afterwards. What you are referring to as the "substitution method" is the guess and check, where you guess the form of solution, like T(n) is O(n log n), and then you prove, generally by induction that T(n)

    • @babbintandukar9959
      @babbintandukar9959 7 років тому +2

      tq bro..very helpful video and you are very helpful interactive teacher giving sugestion for comentators

  • @clovisgu57
    @clovisgu57 6 років тому +1

    crystal clear! thank you!

  • @adolfocarrillo248
    @adolfocarrillo248 11 місяців тому

    Thanks for sharing your knowledge, I got it.🎉

  • @aditric
    @aditric 3 місяці тому +1

    You're awesome!

  • @samwamui
    @samwamui 4 роки тому

    Wow. I don't know how you got O(nlogn) but I'm I'm ready for my test tomorrow.

  • @deveshsingh1479
    @deveshsingh1479 11 місяців тому

    beautifully done

  • @noamansaleem3755
    @noamansaleem3755 7 років тому

    Awesome Bestest Video on Sbstitution Method

  • @weez7
    @weez7 6 років тому

    Ummmmm..
    Can we have 1 or 2 more examples specially with log
    If you don't mind. thank you
    And you explained it superbly

  • @RosieSuh
    @RosieSuh 5 місяців тому

    You are the best, ever

  • @bulbul6
    @bulbul6 6 років тому

    The video is Great. Just give a little introduction in the beginning.

  • @Fr33xII
    @Fr33xII 4 роки тому +1

    Thank you so much

  • @hotchocolate123
    @hotchocolate123 2 роки тому

    great explanation ! thanks a lot

  • @hazerunovn3385
    @hazerunovn3385 4 роки тому

    thank you a lot i was so confused when learning from textbook but now okkkkk

  • @Utopus11
    @Utopus11 5 років тому +1

    Thank you, helped me a lot!

  • @tejaskashyap1392
    @tejaskashyap1392 6 років тому

    Great video! Saved me on my final!

  • @j1995martinez
    @j1995martinez 6 років тому +7

    stupid question: howd you come up with the base case?

    • @anmol-gupta
      @anmol-gupta 4 роки тому +1

      It's given to us with the recurrence relation. Say you have an algorithm, you can always check how many operations are performed for an input size of 1, i.e. the base case here.

  • @hemihobo
    @hemihobo 7 років тому

    Great walk through thank you

  • @superwendel
    @superwendel 5 років тому

    Thanks a lot ! Very simple and useful !!

  • @AuraRazor
    @AuraRazor 3 роки тому

    this was very helpful, thanks

  • @darshilshah3941
    @darshilshah3941 7 років тому

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

  • @OriMoscovitz
    @OriMoscovitz 4 роки тому

    hey, great video, though I would appreciate it if you could another one showing how to solve more complex recursive functions, such as one involving log(n) and without a base case please. would be forever grateful :)

  • @muhammadumairkhan8435
    @muhammadumairkhan8435 6 років тому

    Thank you very for making it so easy for me.

  • @MrAlbashiri
    @MrAlbashiri 6 років тому

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

  • @liangel6135
    @liangel6135 Рік тому +1

    Thank you

  • @louerleseigneur4532
    @louerleseigneur4532 4 роки тому +1

    thanks a lot brother

  • @datim8540
    @datim8540 Рік тому

    Insane video🙏🏻