Solved Recurrence Tree Method

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

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

  • @michaelbowen4275
    @michaelbowen4275 6 ปีที่แล้ว +105

    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.

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

      Yes.

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

      @@dasdawidt No.

  • @ntcool123
    @ntcool123 7 ปีที่แล้ว +143

    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

  • @nile6017
    @nile6017 7 ปีที่แล้ว +113

    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.

  • @christiansakai
    @christiansakai 7 ปีที่แล้ว +57

    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

  • @rahuls331
    @rahuls331 6 ปีที่แล้ว +7

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

  • @AbdulZurghani
    @AbdulZurghani 8 ปีที่แล้ว +140

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

  • @sayyidalisajjadrizavi7418
    @sayyidalisajjadrizavi7418 5 ปีที่แล้ว +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!

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

    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 8 หลายเดือนก่อน

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

  • @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!

  • @fuwuf
    @fuwuf 6 หลายเดือนก่อน +19

    Still helping in 2024

  • @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!

  • @rayjennings1861
    @rayjennings1861 9 หลายเดือนก่อน +5

    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 8 หลายเดือนก่อน

      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.

  • @yoavk
    @yoavk 7 ปีที่แล้ว +6

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

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

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

  • @iramshahzadi8875
    @iramshahzadi8875 6 ปีที่แล้ว +7

    This man deserves a salute
    Awesome explaintation (Y)

  • @rahulpurohit2461
    @rahulpurohit2461 7 ปีที่แล้ว +17

    Damn WHAT YOU DID HERE IS MAGIC.

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

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

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

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

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

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

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

    This was the least complicated explanation. Thanks a lot.

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

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

  • @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 TH-cam. Thanks alot

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

      kollalo mwone....funny tanne

  • @azimjonilkhomov7785
    @azimjonilkhomov7785 5 ปีที่แล้ว +6

    saving lives to this day. Thank You

  • @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

  • @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!

  • @mayankparihar7053
    @mayankparihar7053 7 ปีที่แล้ว

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

  • @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.

  • @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.

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

    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!

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

    very very good explained , thanks Batman

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

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

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

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

  • @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.

  • @SaifUlIslam-di5xv
    @SaifUlIslam-di5xv 4 ปีที่แล้ว

    Got everything in the first attempt. Thanks!

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

    perfect explanation, clear to understand

  • @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 :).

  • @pushparay5554
    @pushparay5554 7 ปีที่แล้ว

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

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

    Thanks Man! This was really nice explanation

  • @nawnitsen7771
    @nawnitsen7771 5 ปีที่แล้ว

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

  • @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 3 ปีที่แล้ว

      @@ramziadil8613 thank youuu!

  • @DarkLordAli95
    @DarkLordAli95 7 ปีที่แล้ว

    short, helpful, and sweet.

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

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

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

    This was amazingly helpful

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

    you are a life saver!

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

    You really made this easy for me !!!

  • @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

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

    best explanation ever

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

    Thank you. This helped clear some things up.

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

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

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

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

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

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

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

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

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

    so clear and easy explanation! thanks

  • @Vupadhayay
    @Vupadhayay 7 ปีที่แล้ว

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

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

    what a helpful video god bless you

  • @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

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

    What a perfect explanation. Thank you so much!!

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

    Very easy explanation, thanks:)

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

    Love from MIT 🥰

  • @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!

  • @feisuxiaozhu
    @feisuxiaozhu 7 ปีที่แล้ว

    very clear presentation, thanks.

  • @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.

  • @arpitajana9051
    @arpitajana9051 7 ปีที่แล้ว

    good explanation sir..it really helped me

  • @Daniel-iy1ed
    @Daniel-iy1ed ปีที่แล้ว

    It was really helpful thanks

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

    Really well done

  • @vaibhavlodha5398
    @vaibhavlodha5398 7 ปีที่แล้ว

    Excellent explanation !! Thank you

  • @AmanPatel-fo6dj
    @AmanPatel-fo6dj 4 ปีที่แล้ว

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

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

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

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

    God bless you.

  • @rockstar2596
    @rockstar2596 7 ปีที่แล้ว

    easy, understandable explanation, thanks!!!!

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

    Best explaination

  • @نوره-ر4ث7و
    @نوره-ر4ث7و 7 ปีที่แล้ว

    Best explanation! Thanks

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

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

  • @fkhatri
    @fkhatri 5 ปีที่แล้ว

    Thanks, John.

  • @chiharuyo
    @chiharuyo 6 ปีที่แล้ว

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

  • @michaelmuse581
    @michaelmuse581 7 ปีที่แล้ว

    Great explanation!

  • @FernandoRodriguez-et7qj
    @FernandoRodriguez-et7qj ปีที่แล้ว +2

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

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

    more videos on recurrence please

  • @MrAlbashiri
    @MrAlbashiri 7 ปีที่แล้ว

    thank you for the amazing video

  • @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.

  • @anonInDE
    @anonInDE 7 ปีที่แล้ว +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?

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

      It's been 3 years, figured it out yet?

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

      T(n)=

  • @tewodroskasahun8721
    @tewodroskasahun8721 7 ปีที่แล้ว

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

  • @SamuelCherukuttyCheruvathur
    @SamuelCherukuttyCheruvathur 7 ปีที่แล้ว

    thanks for the nice explanation :)

  • @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..??

  • @blackfromabove9383
    @blackfromabove9383 5 ปีที่แล้ว

    Really helpful, thanks a lot!!!!

  • @dipenpatel5226
    @dipenpatel5226 7 ปีที่แล้ว

    Thanks. Great Video.

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

    Loved it, Thank 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

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

    Can you please do some more recurrence tree problems

  • @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

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

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

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

    Thanks

  • @oriclesqueiroz
    @oriclesqueiroz 5 ปีที่แล้ว

    Thank you so much!

  • @harishrajora6453
    @harishrajora6453 6 ปีที่แล้ว

    Can I have an example with uneven splits of the tree?

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

    thank you

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

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

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

    Thankyou.

  • @euheath1198
    @euheath1198 7 ปีที่แล้ว

    that helps alot, thank you

  • @sagarmoyganguly4140
    @sagarmoyganguly4140 6 ปีที่แล้ว

    What if there are no other operations beside the recursive call at T(n) level?.... then what will the tree start with?... I just cant figure that out.