Solved Recurrence Tree Method

Поділитися
Вставка
  • Опубліковано 5 жов 2024

КОМЕНТАРІ • 213

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

    My prof spent two hours trying to explain this and no one understood. In 6 minutes you successfully explained something that took my prof two hours to fuck up. Nice job, thank you.

    • @coreytv1338
      @coreytv1338 3 роки тому +7

      I feel this 4 years later...

    • @xdragonflame6563
      @xdragonflame6563 3 роки тому +6

      Literally, same here.... Prof spent 2 hours and I didn't understand a single thing. I watched the first 2 mins of this and understood everything.

  • @michaelbowen4275
    @michaelbowen4275 6 років тому +97

    You did in 6 minutes what my professor could not do in an entire lecture. Thank you so much for clearly explaining the summation step.

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

    CLRS makes it unnecessarily complicated. This clears it up. Thanks!

    • @sharma1337
      @sharma1337 5 років тому +3

      glad im not the only one

    • @TheFotoGuys
      @TheFotoGuys 3 роки тому +5

      I think all textbooks are unnecessarily complicated... However, that book especially is.. yes..

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

      I agree with that

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

      3 years later, Im here, after reading the CLRS.

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

      @@cycv5881 mee too, 5 days later your 3 days later. i have algorithm exam this may

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

    the best explanation of divide and conquer recurrence relation on youtube. Why is this so low in youtube search ranking?

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

      i year later it is still underrated. this is the best thing i saw today

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

    thank you, this is the best explanation i could find in youtube.

  • @tonesaft
    @tonesaft Рік тому +11

    Super helpful example! The only thing that wasn't in this video was why exactly each level splits into two. Turns out it's because for this kind of recurrence equation, of the form " a * T(b) + c " we have: 'a' is the number of times the recurrence is called [in this case "2" because *2*T(n/2) ], 'b' is the input size (usually n/2) and 'c' is the number of operations per iteration (in this case 4n).

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

      So does 'a' refer to the number of branches at each level?

  • @sayyidalisajjadrizavi7418
    @sayyidalisajjadrizavi7418 4 роки тому +29

    Very nicely explained, with proper mathematical reasoning! I have watched both substitution and tree videos. It would be great if you also make one on the master method. Thanks!

  • @rayjennings1861
    @rayjennings1861 8 місяців тому +4

    I think that it's worth noting that each node splits into two branches due to the "2T" part of the recurrence. If it were 3T then there would be three branches from each node, etc.

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

      If the coefficient is bigger than 3 it's still doable but if the branches grow at the same rate. The key is to find the height of the tree for the asymptotic runtime and if the branches grow at different rates then I usually take the one that grows fastest then use the substitution method to verify. Easier said than done of course. CLR 3rd Edition has an example like this.

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

    Great job John. You are teaching the concepts the way they are meant to be taught.

  • @fuwuf5201
    @fuwuf5201 5 місяців тому +11

    Still helping in 2024

  • @patrickmayer9218
    @patrickmayer9218 2 роки тому +1

    *Start out with what you're given (in this case T(n)), and start the tree with everything that is not the recursive call.
    *Do the next recursive call (what's in the parenthesis).
    *Keep doing this until you find a pattern in terms of i.
    *Set the n value for the base case equal to your pattern that you have in parenthesis.
    *Solve for i
    *Do a summation from i=0 to what you found i to be equal to, and this summation is connected to the value at the top of your tree.
    *Multiply the top of tree value by (your i value + 1).
    Still a major pain in the ass, but this video definitely helps!

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

    I have watched several tutorials before this and they all fall short when explaining how they derived their equations from the tree. You did an excellent job here of explaining what your method was. Thanks man!

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

    Great explanation. I couldn't find a simple and clear guide like yours.
    Helped a lot! Thanks

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

    Loved the comparison of the summation to a for loop. Thanks!

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

    This man deserves a salute
    Awesome explaintation (Y)

  • @busbusvlog
    @busbusvlog 6 років тому +5

    I was thinking it's just me who thins CLRS makes things look extremely complicated... I'm relieved to see comments about it. Anyways thanks a lot for the explanation

  • @azimjonilkhomov7785
    @azimjonilkhomov7785 5 років тому +6

    saving lives to this day. Thank You

  • @izzy2815
    @izzy2815 3 роки тому +2

    For once i have understood the tree method and substitution method. THANKS A MILLION!

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

    You make it so simple, thank you so much ! it's just perfectly clear

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

    Damn WHAT YOU DID HERE IS MAGIC.

  • @IPear
    @IPear 2 роки тому +2

    In this case everything is good, but other students need to know that in general, the sum goes from i=0 to (last level)-1, because the last level doesn't cost as much as the other levels generally, cause it's a base case

    • @johnbowers5447
      @johnbowers5447  Рік тому +2

      This is strictly true, agreed. Though the base case can always be thought of as some constant. So if you care about EXACTLY what your recurrence sums to, you have to be careful, and I chose base cases that are easier to deal with. But if you really care about what order of growth (the O(f(n)), instead of the f(n)) your recurrence T(n) belongs in, then it actually doesn’t matter-because changing the base cases, or changing the tree by some constant number of levels, only has the effect of changing the answer by a constant factor or lower ordered terms, so you’ll still land on the correct order of function.

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

      @@johnbowers5447 thank you!

  • @ThefamousMrcroissant
    @ThefamousMrcroissant 6 років тому +2

    Far better than my useless professor. If they had handed me the subjects I could've gotten my entire degree just watching people like you on UA-cam. Thanks alot

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

    This was the least complicated explanation. Thanks a lot.

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

    I like your voice and the way you explain. God bless.

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

    The most precise and best example on the UA-cam. Thanks a lot sir :) Lots of love from Pakistan

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

    Master's and Iteration videos please!!!!! Best recurrence explanations available on youtube ryt now for sure!!!!

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

    wow thank you for the video! I learned this in class but now it's much clearer

  • @SaviourFik934
    @SaviourFik934 3 роки тому +2

    Wow, now I dont have to worry about my exams tomorrow anymore! Thank you, you have saved my life! Like, really!

  • @dasdawidt
    @dasdawidt 2 роки тому +1

    Thank you so much. Now I finally have hope again and I see perspective for my life. Now I can step on to solving the towers of Hanoi.

  • @ramziadil8613
    @ramziadil8613 3 роки тому +3

    This was a great explanation, I do have a question if anyone can answer it, please feel free to. I understand that in this example we are summing up 4n from i=0 to i = log(n), but where is the + 1 term from log(n) + 1 come from (time stamp 5:24). Why eas the + 1 term needed?

    • @ramziadil8613
      @ramziadil8613 3 роки тому +5

      Nevermind I just saw the comment below. If anyone is wondering I will paste what @John Bowers said:
      "If you compute the sum of 1 from i=0 up to some value m, then the result is m+1. For instance let m=2. Then I have i = 0, i = 1, and i = 2; and so if I'm just summing up 1 for each of those index i values, I get 1 + 1 + 1 = 3.
      So sum_{i=0}^m 1 = m+1. If I count starting at 1 instead of at 0, then you don't get the +1: sum_{i=1}^m = m. "

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

      @@ramziadil8613 thank youuu!

  • @likithr.n9692
    @likithr.n9692 4 роки тому +1

    Wow man this was the best explanation so far...

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

    I'm grateful I found this video, wow.

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

    Good explanation. You should make playlist of videos it will help in channel growth

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

      Good idea. I've gotta add it to my to-do list :).

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

    Its videos like this that make wonder why I empty my wallet for school every quarter. Teacher spent an hour on this and you did it better (and cheaper) in 6 minutes.

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

    A six minute video do much much much better than my lecturer! What's wrong with our education....

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

    perfect explanation, clear to understand

  • @pluto5307
    @pluto5307 4 місяці тому

    very very good explained , thanks Batman

  • @SaifUlIslam-di5xv
    @SaifUlIslam-di5xv 4 роки тому

    Got everything in the first attempt. Thanks!

  • @AyaNori
    @AyaNori 2 роки тому +1

    Thanks for this video! I'm just confused why you wrote the base case equals 1 and not 4. If someone could explain I'd appreciate it!

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

    Mayn! youre just amazing! i was so freakin confused about it, but you saved the day. I hope I nail my exam as well. love xx

  • @marekmenczer5493
    @marekmenczer5493 5 днів тому

    Thanks Man! This was really nice explanation

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

    You made it easy. Greatly thankful to you for this easy explanation.

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

    Best explanation ever. Thanks you. You are a life saver.

  • @DanT-iu6oc
    @DanT-iu6oc 4 роки тому +6

    why does 4n/2 have 2 recursive calls? jesus you gotta explain every step man

    • @techduck123
      @techduck123 4 роки тому +4

      because of the 2 beside the recursive call as in 2T(n/2).
      if it was 3T(n/3), it would have three recursive calls each of n/3

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

    Tq u soo mch sir before i had lot of doubts on these topic nw i am ready to solve any problem in these topic nice lecturer tq u sirrr

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

    Thanks! This was quite helpful for my algorithms analysis homework.

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

    Thank you, you are the best.
    I am waiting more tutorials for you ;)

  • @FernandoRodriguez-et7qj
    @FernandoRodriguez-et7qj Рік тому +2

    where did you get the +4n at the end?

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

    so clear and easy explanation! thanks

  • @pkr1kajdjasdljskjdjsadjlaskdja

    wow what a explanation...i love it ..please make more videos to help others ❤❤

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

    You are awesome man.!! Thanks for this video..I have been reading coreman for hours to understand this :(.!!

  • @kevin3d362
    @kevin3d362 12 днів тому

    you are a life saver!

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

    Thank you. This helped clear some things up.

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

    short, helpful, and sweet.

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

    best explanation ever

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

    This was amazingly helpful

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

    You really made this easy for me !!!

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

    What a perfect explanation. Thank you so much!!

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

    Thank you so much i can finally step forward in life.

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

    Very easy explanation, thanks:)

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

    I think for 2^i the total cost has to be 2^i*T(1) which will be 2^i*(4)

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

    more videos on recurrence please

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

    very clear presentation, thanks.

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

    You sir.. deserve to be a professor at MIT.

  • @syedrizvi2687
    @syedrizvi2687 2 роки тому +1

    Thank you so much!

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

    Thanks a lot. But I want to ask just one thing, what about the term = 2(T(n/2))

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

    good explanation sir..it really helped me

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

    what a helpful video god bless you

  • @anonInDE
    @anonInDE 6 років тому +16

    I have a question please... I have this equation that I'm supposed to solve with the tree method:
    T(n) = 4T(n/2) + n^2*log (n)
    I am not given a base case, how can I figure it out?

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

    Excellent explanation !! Thank you

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

    Really well done

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

    Best explaination

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

    Great Video's..I wish you could show the Master Method or Mater Theorem also?

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

    So basically we added 4n log base 2 of n times that makes sense.
    And another question we don't have to count
    Recurring call to the function itself when calculating time complexity..??

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

    great explanation!

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

    Thanks, John.

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

    best best best best best best best best best best best best best best best best best best best best best best best best best best best best best best best best best best best explanation thank you sir.

  • @AmanPatel-fo6dj
    @AmanPatel-fo6dj 4 роки тому

    Отличное объяснение!

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

      Спасибо, господин Президент!

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

    Can you please do some more recurrence tree problems

  • @نوره-ر4ث7و
    @نوره-ر4ث7و 7 років тому

    Best explanation! Thanks

  • @Daniel-iy1ed
    @Daniel-iy1ed Рік тому

    It was really helpful thanks

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

    At 5:21, do you mean the sum equals log2n, or goes 4n + 4n ... + log2n? Don't understand what mean by log2n in the curly brackets. Also confused as to why you decided to convert the sum at the end.

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

      I think the idea is to get it to an equation, so that would explain why he converted the sum at the end. However, I'm a little confused on where the extra +1 came from lol.

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

    easy, understandable explanation, thanks!!!!

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

    Great video, thank you for your time! What kind of pen do you use?

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

    Love from MIT 🥰

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

    please tutor me. my class is using CLRS and idk what's going on

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

    God bless you.

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

    If T(1) = 4 shouldn’t you solve for 4 = 2/n^i? I thought when you are solving for height you use the actual base case. I don’t understand why you do T(1) = 1. (Minute 4:29). Please help

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

    Loved it, Thank You :)

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

    thank you for the amazing video

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

    thanks for the nice explanation :)

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

    Thanks. Great Video.

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

    You do not use T(1) =4 at all here, as if the answer would be the same if T(1) = 500.

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

      Good point. The T(1)=4 base case is contrived so that the leaves of the tree have the same values as the internal nodes (i.e. 4n). If the base case does not agree with the non-recursive part of the main recurrence, then you have to be a bit more careful, take your tree only down to the level just above the leaf nodes, and then handle the leaf nodes in a separate step (which is just number of leaves * base case value).

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

    What if there's no base case? How do I decide one?

  • @sayasark
    @sayasark 6 років тому +4

    Why log2(n) ? Everything is understandable except the number of levels.

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

      Sayan Sarkar look up exponential and logarithmic properties. He doesn't explain it but he basically flipped the fraction into a log.

    • @fatimahz7182
      @fatimahz7182 6 років тому +3

      1 = n/2^i *=>* 2^i = n
      "i" is the power of 2 and to make "i" the subject, by using the exp. and log. properties(to bring something _down_ from "power" you gotta do _log_ of something on the other side of the equal sign, which is "n"), it becomes *log(n)* and 'cause "i" was the *power* of 2, it's log *2* (n). Thus, *i = log2(n)*
      Hope it helped :)

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

    Really helpful, thanks a lot!!!!

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

    I was following along, and I thought well, but I don't understand how you conclude that it will terminate when 1 = n/2^i..? You imply it's obvious but I don't get it

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

      Bro.....in recursion, you stop when you arrive at a problem to which you know solution right????
      In this case, it is T(1).
      You already know solution for it....so, it is the base case, you stop there

  • @jha-bhaskar
    @jha-bhaskar 7 місяців тому +1

    Awesome❤

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

    Master method with recurrence make video plz

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

    now i am more confused how is he making two recursive calls from the 4n i am doing a question in which there are three recursive calls now i am confused man