2.1.4 Recurrence Relation T(n)=2 T(n-1)+1 #4

Sdílet
Vložit
  • čas přidán 10. 09. 2024

Komentáře • 231

  • @Rj_DSD
    @Rj_DSD Před 5 lety +184

    You are gem sir.

  • @sarvagyamaithani2093
    @sarvagyamaithani2093 Před 3 lety +99

    i would never understand DAA if you weren't here in this planet. Love you Abdul sir. And yes, we want more Abduls like you !

  • @asishraz6173
    @asishraz6173 Před 4 lety +50

    Finished this video and with this, finished my daily task of watching 3-4 videos from this playlist.

  • @study-me1oe
    @study-me1oe Před 2 lety +72

    For anyone who's confused at 10:16, here is the answer
    that 2ⁿ+2ⁿ= 2(2ⁿ) = (2¹) (2ⁿ) = (2ⁿ⁺¹)

    • @vansh6183
      @vansh6183 Před 2 lety

      how 2^k-1 ? at above step at 10:10

    • @charbelfayad506
      @charbelfayad506 Před 2 lety +1

      @@vansh6183 1+2+...+2^(k-1) is an algebraic summation which id equal to 2^k -1

    • @muhammedshaheen5176
      @muhammedshaheen5176 Před rokem +10

      for anyone who is confused at this comment, don't worry confusion is universal

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

      i was confused but its a little mistake made by me, sir did the correct sollution

  • @abdulrakib4820
    @abdulrakib4820 Před 6 měsíci +105

    Anyone watching in 2024 ? 🙃

  • @kevincarman1
    @kevincarman1 Před 4 lety +41

    You are a much better professor than the one I pay too much money for. Thank you for this wonderful series of videos.

  • @kingdeath1007
    @kingdeath1007 Před 4 lety +48

    1:46 Recursive Tree Method
    5:05 note 1_
    6:42 Substitution Method

  • @subramaniyanvg6367
    @subramaniyanvg6367 Před 3 lety +37

    Difficulty increases by each video. When I get stuck I refer previous videos in the playlist. Very nicely you have ordered the playlist till now. Thank you again sir.

  • @ousmaneouedraogo8262
    @ousmaneouedraogo8262 Před 4 lety +15

    I have learnt more with you in English although that my English level is not so high than my algorithm teacher in French

  • @P3R5I3dark
    @P3R5I3dark Před 4 lety +14

    I love that after first lessons I can try to solve these by myself and when i succeed it is a big satisfaction!

  • @anchalvias9224
    @anchalvias9224 Před 4 lety +7

    Thank you so much sir... Your teaching is awesome.
    Really liked the way you have clarified all the concepts step wise step.
    You are great.

  • @sayakbanerjee4592
    @sayakbanerjee4592 Před 5 lety +3

    Whoever is editing these videos, has a great sense of humor

  • @amruteshmishra4921
    @amruteshmishra4921 Před 4 lety +26

    Someone hammered my head at 1:00 ! :P

  • @moudhafferbouallegui
    @moudhafferbouallegui Před rokem +2

    Saved me 3 years ago as I was getting my bachelor's in computer science and here u are again sir saving me again as I'm getting a bachelor's in software engineering.

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

    No.1 Algorithms lecturer in the world.

  • @sirgemahender6148
    @sirgemahender6148 Před 5 lety +24

    speed @ 1.5 ..😊😄...Perfect
    thanks a lot sir for the lectures...

  • @Joppan435
    @Joppan435 Před 6 měsíci +10

    Guys, I finally found out why he wrote ( (2^(k+1)) -1 ), instead of (2^k)-1. So, let me make is as simple as possible, because I was also stuck on this very simple doubt for 2 hrs. If we all got a doubt here, it clearly means that we did not count the number of terms. Let's take 2 cases first. See this -> 2^(n-1) + 2^(n-2)+ . . . . . . . . + 2^(2) + 2^(1) + 2^(0). This GP is from 0 to n-1, now, If i tell you to count from 0 to n-1 where n=4, you would totally count 4 digits. That is 0 1 2 3. So there are 4 terms. Just like that for the above equation that I wrote, we have n terms. So, now let's use that general GP formula that we all know about, that is a(r^k -1)/(r-1). You will get 2^n-1 as answer. BUT, BUT, BUT, We all want to know why on earth we all got 2^(k+1) - 1 right. It's really simple. Just like I told you that there are 2 cases. The 1st case was the first equation that I asked you guys to count. Now, I will give you guys another equation as case 2. This equation is the same equation that we will get exactly @10.06 which is 2^n + 2^(n-1) + 2^(n-2) + . . . . . . . . . + 2^0. Now look at this equation really carefully and try to count how many terms there are in this equation. It goes from 0 to n, and not from 0 to n-1(just like in case 1). So let me ask you something, if I asked you to count from 0 to n, instead of n-1, where n=4, you will count 5 terms, that is 0 1 2 3 4. which is n+1 and not n. NOW YOU GOT IT??. in case 2, you can see that there is a an extra term called 2^n. That is the reason we take from 0 to n, instead of 0 to n-1. Instead of just writing this as the next step of the GP equation substitution, he directly wrote it as ( (2^(k+1)) -1 ). That was why we got confused. I really hope this helped everything, as This took about 2 hrs. for me to find and come up with a explanation this detailed.

    • @Ari-pq4db
      @Ari-pq4db Před 4 měsíci

      Thanks 😄

    • @ivandrofly
      @ivandrofly Před 4 měsíci +1

      Ookay…

    • @jallurimahesh1515
      @jallurimahesh1515 Před 4 měsíci +1

      0 to k has k+1 terms. generally if we take 1 to k terms which is k terms, that is why the formula is bit modified

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

    The best channel for advance algorithms and DSA

  • @g.c415
    @g.c415 Před měsícem

    such crisp and crystal clear lectures. amazing

  • @pkr619
    @pkr619 Před 3 lety +6

    I am new to your channel, just watched a couple of videos, and am totally hooked. The quality and depth are superb. Subscribing to your channel, and heartful gratitude for putting out such amazing videos. Thank you!

  • @bryancorea678
    @bryancorea678 Před 3 lety +5

    Sir we really need more videos of you, great teacher, love your explanations
    Greetings!

  • @kamranaesthetics
    @kamranaesthetics Před 2 lety +1

    Allah pak apko sahat wali lambi zindagi dy or hmesha khush rakhy....❤️

  • @anshikatyagi4624
    @anshikatyagi4624 Před 3 lety +2

    Bestest videos on utube.

  • @ahanatasmim15
    @ahanatasmim15 Před 6 měsíci +2

    Dear Abdul Bari sir, how you keep track of all these information in ur brain? my brain is already rebooting and I am only half way through your playlist. I just want to let you know that this playlist was really helpful. I might not get a good grade in algorithm but I have surely learned better and thank you for that

  • @ann-malapilga5049
    @ann-malapilga5049 Před 2 lety +1

    You explained everything very well and I appreciate your step by step explanation.
    Thanks much.

  • @NeelSandellISAWESOME
    @NeelSandellISAWESOME Před 4 lety +7

    TLDW: Every call has 2 more calls so 2(n-1) = 2(2(n-2)) = 2(2)(2)(n-3), as you can see we are tacking on a 2 each time so 2^n is the worst case

  • @rajnisoundararajan669
    @rajnisoundararajan669 Před 4 lety +7

    How would the second Test(n-1) be executed?

  • @stevenf6636
    @stevenf6636 Před 5 lety +6

    great explanation, very helpful thank you!

  • @parasmyname784
    @parasmyname784 Před 5 lety +3

    Sir you are God of algorithms for us

  • @bharanidharan.m4245
    @bharanidharan.m4245 Před 3 lety +10

    T(n)=2T(n/3)+5n
    what's the complexity of these equation?

  • @srikanthsrigiri6911
    @srikanthsrigiri6911 Před 3 lety +2

    Great Explanation. Thank you for the efforts

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

    Excellent, I was looking for this

  • @vakhariyajay2224
    @vakhariyajay2224 Před 2 lety +1

    Thank you very much. You are a genius.

  • @indiajackson5959
    @indiajackson5959 Před 2 lety +1

    This explains how binary tree recursion works!! OMG!!

  • @NaxoHD
    @NaxoHD Před 3 lety +2

    Grande Abdul!

  • @110-himanshurai5
    @110-himanshurai5 Před 4 lety +3

    Aap nhi hote to hmara kya hota sir.
    Thank you very much.

  • @fauzangolawala7974
    @fauzangolawala7974 Před 2 lety

    GREAT GREAT GREAT WORK SIR!!!!!!!!
    Just loving your teaching
    Need more of courses from your side
    Need more teachers like you!!!!!!

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

    Short and comprehensive. Thank you very much for your help!

  • @momos.khilado
    @momos.khilado Před 2 lety +1

    damn , for the first time in my life I found this easyyy

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

    OMG thank you very much!!!! i finally could understand!!

  • @thetech685
    @thetech685 Před 2 lety +3

    Hello sir, I was wondering, isn't the sum of a gp series have the formula- Sum= a((r^n)-1)/r-1
    I see you used r to the power of n+1? Is it a special case here?

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

      because there are n+1 terms (ik the comment is an year old but it is to help the future students who will study from this video)

  • @WimpyWarlord
    @WimpyWarlord Před 5 lety

    Somebody give this man a medal.

  • @N-e0N
    @N-e0N Před 3 lety +3

    Isn't the sum of n terms of a GP = a[(r^n -1)/(r-1)] ? That's what I saw when I searched, and not r^(n+1) -1

  • @Han-ve8uh
    @Han-ve8uh Před 3 lety +2

    Interesting to note in all 3 previous videos, the substitution method (counting number of calls) produced a result 1 more than recurrence tree (counting number of prints) method. However in this example of 2T(n-1), these 2 methods both give 2^(n+1)-1. I guess this is because now, the tree method was also counting all the 2^k leaves of T(0), whereas previous videos never counted T(0) in tree method?

  • @ivandrofly
    @ivandrofly Před 4 měsíci +1

    From 8:21 everything is explaining :D

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

    That was awesome. Thank you so much for your help.

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

    On 10:16, is that right?

  • @TCfrli
    @TCfrli Před 3 lety

    You are perfect sir.I can understand these lesson.Thanks a lot

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

    Nice 🌺

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

    I love you Abdul!

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

    Perfect👍🏼👍🏼👍🏼👍🏼 thanks, please keep going

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

    Very useful!

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

    Great Sir!!!!

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

    Thank you..

  • @surentharrajamohan8185

    Sir you are truly a legend

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

    How did you simply: 2^(n) + 2^(n) - 1 to 2^(n+1) - 1. At 10:12

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

      its easy just look carefully it will form sum of gp formula

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

      @@Shubham_30_12 could you explain please

    • @_iftkhr_
      @_iftkhr_ Před 2 lety +1

      2^n + 2^n - 1 = 2*2^n - 1 = 2^(n+1) - 1

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

      2^n + 2^n = 2^(n+1)
      Reason:
      Let n = 2
      2*2 + 2*2
      We have 2*2 two times
      2*2*2 the last 2 is 1 in (n+1)
      We are duplicating the 2*2 to give us 2*2+2*2
      Note: the base 2 is important as if it was 3 then we would have triplicate the product of power.
      let n = 2
      3^n + 3^n
      3*2 + 3*2 = 3^(2+1)
      (3*3) + (3*3) + (3*3) = 3*3*3

  • @SRNR_PODCAST.
    @SRNR_PODCAST. Před 3 lety +1

    a gold mine in youtube

  • @NPRATTIPATIANILKUMAR
    @NPRATTIPATIANILKUMAR Před 3 lety +3

    What happens if I remove "if" condition incase of substitution process ?

  • @hussamcheema
    @hussamcheema Před 6 lety +6

    How is 1+2+3+...+2^(k-1) = (2^k) - 1?

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

      this is not exactly what is shown in the video ,,actually the obtained series was 1+2+2^2+2^3+2^4+....+2^k and this forms a Gp series ..and sir has clearly shown in the video how to calculate it..

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

    sir you are the best!!

  • @rohandilip4173
    @rohandilip4173 Před 3 lety +5

    I am having some doubt regarding sum of the geometric mean
    5:35 Sum of a GP is a(r^k -1)/r-1 and not a(r^(k+1) -1)/r-1. Where did that k+1 term came from?
    It would be really helpfull if someone replies

    • @shubhashish7022
      @shubhashish7022 Před 3 lety +5

      Look at the number of terms. They're starting from a*r^0 and going upto a*r^k, hence, k+1 terms and a(r^(k+1) -1)/r-1. Had it been starting from a*r^1, it would have been a(r^k-1)/r-1.

    • @vaishnavidubey6782
      @vaishnavidubey6782 Před 3 lety

      @@shubhashish7022 thanks, now understood😌

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

    obrigada cara, salvou demais

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

    Excellent!

  • @akankshasingh9242
    @akankshasingh9242 Před 4 lety

    In above when 2^n T(0) + 1+2+2²+......+2^n-1
    Here when we put the value of n so that T(n) become T(0) so as 2^n should become 2⁰
    .
    . . 2^n + 2^n -1 = 2⁰ + 2⁰ -1 = 1+1-1= 1
    Hence, T(n)= 1
    Sir give me some thoughts

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

    Great!!!

  • @nouf5184
    @nouf5184 Před 2 lety +1

    Thank You!

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

    Hello Sir, Your teaching is amazing. I need help on Recurrence Relation if T(n) = 3T(n/3) + log n, then what will be the complexity for this relation.

    • @khushiagarwal9173
      @khushiagarwal9173 Před 4 lety

      @@abdul_bari thank u sir.. but sir if i have to explain this then how i will write in my paper

    • @marcielledepaula3373
      @marcielledepaula3373 Před 4 lety

      @Kenneth Lieu but n have to log n and not its

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

    Sir in the recurrence tree you made I think the tree should be ended with leaf nodes T(n-k) and not T(0) after tracing it for k steps. Though the tree wouldn't be complete if it is further traceable so we will trace it for n steps and hence summation of all those terms will be taken for n steps and which is how we will get the function T(n)=2^(n+1)-1

  • @more-uv4nl
    @more-uv4nl Před 6 měsíci

    thanks alot sir !

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

    What is the solution of this recurrence T(n)= (xn)+((1-x)xn)+cn

  • @mohammedadel8948
    @mohammedadel8948 Před 2 lety

    Thank you for your hard work.

  • @anchalpandey9074
    @anchalpandey9074 Před rokem

    an example of algorithm using this recurrence relation could be tower of hanoi problem

  • @vaishaliwadhwa8742
    @vaishaliwadhwa8742 Před rokem

    Very nice

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

    omg thank you so much

  • @RoshniSarda0608
    @RoshniSarda0608 Před 2 lety +1

    The formula for GP series goes as Sn = a[(r^n-1)/(r-1)] if r ≠ 1and r > 1

    • @RoshniSarda0608
      @RoshniSarda0608 Před 2 lety

      i m confused about the formula you mentioned in the video for GP at time 5.42 in the video.

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

    thank you very much sir !

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

    *Congratulations for 200K+ Subscribers Sir* ..

    • @TechnoDB
      @TechnoDB Před 4 lety

      @@abdul_bari : Welcome Sir..

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

    Sir, I think you got the sum of gp formula wrong, it will be 2^k - 1

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

    jazakALLAHH

  • @hrishikeshaddagatla4789
    @hrishikeshaddagatla4789 Před 2 lety +1

    10:16 it must be 2.2^n - 1

  • @Aarti-Sweetshots
    @Aarti-Sweetshots Před 3 lety +1

    Become a Big Fan of you🙏

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

    Thanks sir

  • @second_second_
    @second_second_ Před 3 lety

    why when put into code, T(3) = 7 = 2^3 -1, but not 2^(3-1) - 1 ?

  • @chandradevyaduraj6046
    @chandradevyaduraj6046 Před 3 lety

    You are great sir.....

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

    Hello sir, in 10.03 you substitute the geometric series formula as (2^k)-1, but in 5.31 when you write the formula isn't it suppose to be ( (2^k)-1/(r-1) ) instead you wrote ( (a(r^(k+1)) -1)/(r-1) ) and so in 4.58 you wrote ( (2^(k+1)) -1 ). May i know why you write k+1 in here instead of k only?

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

      I was quite confused about this too. According to the formula I know for the sum of gp series would be (2^k)-1/2-1. Not quite sure why its different here

    • @Joppan435
      @Joppan435 Před 6 měsíci +1

      Guys, I finally found out why he wrote ( (2^(k+1)) -1 ), instead of (2^k)-1. So, let me make is as simple as possible, because I was also stuck on this very simple doubt for 2 hrs. If we all got a doubt here, it clearly means that we did not count the number of terms. Let's take 2 cases first. See this -> 2^(n-1) + 2^(n-2)+ . . . . . . . . + 2^(2) + 2^(1) + 2^(0). This GP is from 0 to n-1, now, If i tell you to count from 0 to n-1 where n=4, you would totally count 4 digits. That is 0 1 2 3. So there are 4 terms. Just like that for the above equation that I wrote, we have n terms. So, now let's use that general GP formula that we all know about, that is a(r^k -1)/(r-1). You will get 2^n-1 as answer. BUT, BUT, BUT, We all want to know why on earth we all got 2^(k+1) - 1 right. It's really simple. Just like I told you that there are 2 cases. The 1st case was the first equation that I asked you guys to count. Now, I will give you guys another equation as case 2. This equation is the same equation that we will get exactly @10.06 which is 2^n + 2^(n-1) + 2^(n-2) + . . . . . . . . . + 2^0. Now look at this equation really carefully and try to count how many terms there are in this equation. It goes from 0 to n, and not from 0 to n-1(just like in case 1). So let me ask you something, if I asked you to count from 0 to n, instead of n-1, where n=4, you will count 5 terms, that is 0 1 2 3 4. which is n+1 and not n. NOW YOU GOT IT??. in case 2, you can see that there is a an extra term called 2^n. That is the reason we take from 0 to n, instead of 0 to n-1. Instead of just writing this as the next step of the GP equation substitution, he directly wrote it as ( (2^(k+1)) -1 ). That was why we got confused. I really hope this helped everything, as This took about 2 hrs. for me to find and come up with a explanation this detailed.

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

    3𝑇 ( 𝑛-2) + c , can you explain this why its O(3^n/2) more explain pls

  • @rahulchoudhary7903
    @rahulchoudhary7903 Před 2 lety

    Sir i think sum of gp series formula is wrong ... Could you cross check once sir?

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

    good job sir

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

    Why don't we multiply the height of the tree?

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

    thank you, sir, u rly amazing

  • @danielrotnemer2564
    @danielrotnemer2564 Před 2 lety

    Great! Thank you

  • @nikitasinha8181
    @nikitasinha8181 Před 2 lety

    Thank you

  • @avijitdey6998
    @avijitdey6998 Před 2 lety

    the gp series upto 2^k is a(r^k-1)/r-1, so why we taking a(r^(k+1) -1)/r-1

  • @rishikashukla2045
    @rishikashukla2045 Před 4 lety

    in one previous video you have taken n unit of time for printf but in this you have taken 1 unit of time for printf

  • @gauravbhole1049
    @gauravbhole1049 Před rokem

    love yoou sir

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

    Isn't it n times that print statement inside the if will execute? Why is it counted as 1?

    • @Joppan435
      @Joppan435 Před 6 měsíci +1

      we are not taking the frequency of the statement, instead we are taking the amount of time that is required for that statement to run just one time, that is "1".

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

    Hi, can you provide an answer for T(n-1) + T(n-2) + 1?
    I know for a fact that it is O(2^n)
    But how do you expand this using iteration method?
    Thank you.

    • @luigicennini2069
      @luigicennini2069 Před 4 lety

      @@abdul_bari i don't understand. Why can't it be solved?

  • @hrishikeshaddagatla4789

    Actually Sum of gp is a(r^k-1)/r-1 right?

  • @amal5390
    @amal5390 Před 2 lety

    GOOD JOB

  • @nasirkhn277
    @nasirkhn277 Před 6 lety

    Sir why here we can take time for T(n)=1 instead of T(n)