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

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

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

  • @emelyloria7467
    @emelyloria7467 5 ปีที่แล้ว +406

    Teaching is a talent!! You're one of the best teachers I've known. I should have found your channel before.

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

      I wish I had found this channel before I took algorithms. I would have aced everything :)

    • @user-wc1sm8cj8s
      @user-wc1sm8cj8s 4 ปีที่แล้ว

      mw too

  • @m7mdarwani964
    @m7mdarwani964 3 ปีที่แล้ว +517

    For Calculus, we have Prof. Leonard & for Algorithms, we have teacher Abdul Bari. Thank God

    • @fritz6600
      @fritz6600 3 ปีที่แล้ว +6

      Indeed. Haha.

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

      For linear algebra we have Gilbert Strang.

    • @shreya-tf5go
      @shreya-tf5go ปีที่แล้ว

      🙂🙂

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

      Prof. Leonard saved my undergrad calculus!!!

    • @cancali
      @cancali 11 หลายเดือนก่อน +1

      Do you have recommendations for Physics (1&2) and Circuit classes? I CANNOT deal with these..

  • @michaelekoka3263
    @michaelekoka3263 5 ปีที่แล้ว +113

    Excellent teacher.
    As he said, adding the n gives 2n-1, 3n-2, etc, making the pattern a bit less obvious and the expression a bit more difficult to solve. But sometimes we have to live dangerously, so here we go:
    T(n) = T(n-1) + n
    T(n) = T(n-2) + 2n - 1
    T(n) = T(n-3) + 3n - 3
    T(n) = T(n-4) + 4n - 6
    ...
    T(n) = T(n-k) + kn - [(k-1) + (k-2) + ... + 3 + 2 + 1]
    Assuming n-k = 0; k = n
    T(n) = T(0) + n² - [(n-1) + (n-2) + ... + 3 + 2 + 1]
    Isolating the expression in brackets
    [(n-1) + (n-2) + ... + 2 + 1]
    We know that
    n + (n-1) + (n-2) + ... + 2 + 1 = n(n+1)/2
    Taking off n from both sides we get
    (n-1) + (n-2) + ... + 2 + 1 = (n(n+1)/2) - n
    which resolves to
    (n(n+1)/2) - 2n/2 => (n(n+1) - 2n)/2 => (n(n+1-2))/2 => n(n-1)/2
    Plugging it back in the equation in its new form
    T(n) = T(0) + n² - [n(n-1)/2]
    Removing the brackets and swapping the sign
    T(n) = T(0) + n² + n(1-n)/2
    T(n) = 1 + (2n² + n(1-n))/2
    T(n) = 1 + n(2n+1-n)/2
    T(n) = 1 + n(n+1)/2

    • @ajaypanthagani5959
      @ajaypanthagani5959 5 ปีที่แล้ว +8

      its T(n) = T(n-3)+3n-3
      I think

    • @michaelekoka3263
      @michaelekoka3263 5 ปีที่แล้ว +7

      ​@@ajaypanthagani5959 Sequence is indeed 1 3 6 10... Good catch, thanks!

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

      I would like to ask, where did 2n^2 came from after removing and swapping the sign? did you just plugged in a constant c to get n(n+1)/2?

  • @Usertyspr
    @Usertyspr 3 ปีที่แล้ว +22

    Greatest teacher of Algorithms . Even my college teacher(dsa) first watchs your videos the he teaches us .....He completely try to copy but couldn't .

    • @Mlakshman-w9k
      @Mlakshman-w9k 9 หลายเดือนก่อน

      unique art of abdul bari sir..

    • @HeerModi-vv1jm
      @HeerModi-vv1jm หลายเดือนก่อน

      So relatable 😂😅

  • @ravigupta4252
    @ravigupta4252 4 ปีที่แล้ว +31

    Before finding your videos, I was very scared of CSE subjects but now I m becoming hero in algorithms 👍

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

      Did you got placed bro?

  • @amberpradhan2484
    @amberpradhan2484 4 ปีที่แล้ว +32

    Hello Sir, You are the best teacher so far. God bless you and your family. Thank you for sharing your knowledge which is helping us a lot.

  • @sarfarazkhanbiradar544
    @sarfarazkhanbiradar544 4 ปีที่แล้ว +6

    I have started admiring you Abdul !!! Wish every teacher/instructor be like you. Thank you

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

    The way u have delivered it..... really made it very easy to understand.that is the beauty lies in this lecture.

  • @elitesquad8231
    @elitesquad8231 3 ปีที่แล้ว +9

    Teaching is an ART and you are the ARTIST 🔥🔥🔥🔥

  • @coderopes2983
    @coderopes2983 5 ปีที่แล้ว +59

    Study is beautiful with u sir✌️👍🏻✌️

  • @knarice
    @knarice 3 ปีที่แล้ว +14

    I have passed my data structures course by these lectures and now finally understanding algorithms. Thank you very much

  • @mohammedal-khulaifi7655
    @mohammedal-khulaifi7655 3 ปีที่แล้ว +7

    best algorithm teacher in the world

  • @kingdeath1007
    @kingdeath1007 4 ปีที่แล้ว +19

    Recursive Tree Method 3:24
    Substitution Method 7:47
    note 1 9:16-9:49
    note 2 13:39-13:48

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

    one of the best lecture on Algo... I HV ever listened........

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

    Teaching is an art and abdul sir ,you are an artist of it. Cool, calm and composed teaching!!!!

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

      kuch samjh nahi aaraha bro
      \

  • @priyankamanna4550
    @priyankamanna4550 4 ปีที่แล้ว +8

    Your teaching skill is super. I really understand each and every thing you taught and my concepts are really cleared out after watching this.. I hope you make more such video on programming concepts .😀

  • @SadiaAmin-u4q
    @SadiaAmin-u4q 2 หลายเดือนก่อน

    Sir i took DAA course two times and failed both times and just couldn't understand this subject at all, i came across your playlist and it made my life so much easier. i thought i just couldn't understand this subject and felt really hopeless. thankyou so much for this amazing playlist, you are truly a gem.

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

    There should exist more people like you in the world! Thank you

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

    This is the best tutorial I have ever watch on youtube.

  • @ryzurrin
    @ryzurrin 3 ปีที่แล้ว +6

    You good sir have just expanded my brain and my wisdom, thanks for the great lessons!

  • @devanshkhare3532
    @devanshkhare3532 4 ปีที่แล้ว +11

    Sir, ar 5:51 you took T(0) will take 0 time. But you also said that 0 time means constant time so we take 1 instead of 0.
    So, for summing up, if taken 1 instead of 0 sum should be = n(n+1)/2 +1 .
    I know it wont make a difference in the final answer but just wanted to confirm if I am theoritically correct or not ?
    Please do reply and Thank you in advance !

  • @pedronieto1584
    @pedronieto1584 10 หลายเดือนก่อน +2

    Yessss this is just what I needed. Thank you Prof Bari!

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

    When you said "Hello friends" at the beginning, I couldn't help but smile.

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

    Thank you sir. Your videos will help me pass this examination. Thank you hundred-fold.

  • @wirito
    @wirito 5 ปีที่แล้ว +21

    8:50 when you go to office hours and the professor has already explained it twice and you say: I still don’t get it professor.

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

    Sir the way you teach every concept get's clear.....thanks a lot sir you are making future of many students bright...keep going sir

  • @abhishek7969
    @abhishek7969 6 ปีที่แล้ว +10

    learning a lot from ur videos

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

    This man's breathtaking!

  • @deepanshuchoudhary4598
    @deepanshuchoudhary4598 5 ปีที่แล้ว +40

    I thought you would slap me :p :p @ 8:54

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

    sir you are best, with best explanation i got till now. i was never understanding these algorithms because nobody actually knew it completely and never explained them fully. so i always cramed them , which i never like😂. Thank you a lot for keeping and incresing my interest in programming😊.

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

    WOW three lectures I couldnt understand, then this guy comes along and I understand it in 3 minutes.

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

    You have a natural way to explain these things. Exceptional videos. Would like to learn OS or python, java from you. Thank you.

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

    Sir you are very accurate and to the point, and also I love to watch your videos as you are accurate with your way of teaching....

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

    In 1:03, why did we say n+1 for "for loop"?

  • @loviisamaenpaa6452
    @loviisamaenpaa6452 5 ปีที่แล้ว +24

    Thank you!! Finally I got this, thanks to you!

  • @AnujKumar-tt5md
    @AnujKumar-tt5md 4 ปีที่แล้ว +2

    Sir... You are a gem 💎 among teachers. Thanks🙏

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

      It's my pleasure

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

    You deserve nothing but happiness and great things in your life! I cant thank you enough!

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

    Should mention that 1 + 2 + 3 + .... n-1 + n is a summation that can be shorthanded to equal n(n+1)/2

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

      Glad I saw that comment thanks buddy

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

      You sir are a lifesaver

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

      It’s a basic concept in math probably a 9th class kid knows it.

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

      @@b088mohdzaid5 for people who haven’t been in math class for a long time, they can forget

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

    Huge respect
    To Bari sir, for deep knowledge.

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

    Hi sir , your videos are really great and helpful!!Thank you so much for them.
    I was having a doubt at the divide part at 6:03.
    can't we simply use the method provided in previous video,the method of " repeating the relation for k times and analysing at k= n"?i.e:
    We had the relation T(n)=T(n-1)+ n ----(1)
    if we replace by n-1, it becomes T(n-1)=T(n-2) +n-1 ----(2)
    putting back in (1), we get : T(n) =T(n-2) + 2n -1 -----(3)
    similarly we get T(n)=T(n-3) + 3n -2
    similarly we get T(n)=T(n-4) + 4n -3
    similarly we get .....
    similarly we get ..... {for k times }
    similarly we get .....
    similarly we get T (k) =T(n-k) +kn -(k-1)
    now assuming n=k,
    T(n) = T(0) + n^2 - n +1
    => T(n) = 1 +n^2 -n +1 = n^2-n+2
    => complexity is O(n^2)
    will it be wrong?

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

      its correct

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

      Yes it's wrong. Try for T(n-5). It won't satisfy when u substitute k=5

  • @shreemaan-abhishek
    @shreemaan-abhishek 3 ปีที่แล้ว +6

    Here he is! The man, the myth, the legend!

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

      What a coincidence bhaiya!! I was also watching algorithm and you too

    • @shreemaan-abhishek
      @shreemaan-abhishek 3 ปีที่แล้ว

      @@pratapujjwal4642 :D

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

    Teaching is a talent and sir has done masters in it

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

    Thank you sir
    You helped me a lot.

  • @AbhishekYadav-wc5vz
    @AbhishekYadav-wc5vz 4 ปีที่แล้ว +4

    14:13 Itna solve krne ke baad... Mahaul badal gya, zazbaat badal gye ;)

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

    yes sir you teaching method is very good

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

    Sir, loves your videos! Finally i can understand Algorithms in a simple way. Please continue to create more videos! Hope u can cover every Advanced Algorithms as in Cormen’s textbook.Thanks!

  • @arindamroy7671
    @arindamroy7671 6 ปีที่แล้ว +4

    A probable rectification - Since T(0) is never written as 0 as instructed by you in the previous video , T(0) in the execution depiction should be equal to 1not 0. So it should be 1+2+3+......+ n-1+n = n(n-1)/2 .

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

    really awesome explanation sir all software engineers

  • @ChauDang-bm1nf
    @ChauDang-bm1nf 10 หลายเดือนก่อน

    Please make videos of computer architecture. You’re teaching skills is brilliant.

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

    Thanks for helping me obtain my degree :)

  • @muhammadshaban9119
    @muhammadshaban9119 3 ปีที่แล้ว +6

    Sir in loop,why we write n+1 and n?
    Also I am a bit confused in writing a recurrence relation whether n+1 or n.
    Sir kindly explain me in details.
    Thanks....

    • @SA-rk4ku
      @SA-rk4ku 3 ปีที่แล้ว +8

      the loop runs n times but at last time n+1 it also checks if the condition is true or not , hence it takes CPU one extra cost to check loop last time ,even if body of loop is not executed....

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

    All colleges that teach data structures should fire their hopeless lecturers and just play this video. Immense respect for Abdul Bari

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

    I really initially thought that the answer should be O(n) as there is one for loop. I was clearly wrong. Thank you sir for explaining this soo elegantly and making us better students

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

    I appreciated the video a lot, thanks from Poland

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

    I need help understanding the part where you say that 1 is added in T(n) = 1 + n(n - 1)/2 because it is for the number of calls.
    What do you mean by number of calls?

  • @arrogantermistkerl4579
    @arrogantermistkerl4579 5 ปีที่แล้ว +13

    He's staring that knowledge into my head

  • @AlokSingh-jw8fr
    @AlokSingh-jw8fr 3 ปีที่แล้ว +2

    At 1:05 why sir has taken n+1 for , for loop?
    if anyone knows then please do tell me.

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

      In the 'for' loop initialisation i = 0 takes constant time 1 and condition check, increment operation takes n times, so n+1 is for the 'for' loop alone and n is for the printf statement inside loop, so summing up loop parts only = n+1 + n = 2n +1 where the printf and condition check/increment operation both take n times so ....for asymptotic analysis 2n+1 can be reduced to n+1....also the outer guarding if statement has 1 time constant adding it up makes n+2 which again can be reduced to n or n+c where c doesn't matter in asymptotic Big O.
      That's why the in the final eqn 2n+2 is reduced to just n.

    • @ARULV-zc5ki
      @ARULV-zc5ki ปีที่แล้ว

      @@mahee96 🤝

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

    Thank you sir...tomorrow is our exam and your lectures are ssly a saviour for us.....it easily made us understand the concept one night before the exam....👍

  • @tictacricrac
    @tictacricrac 9 หลายเดือนก่อน +1

    In fields where legends freely roam,
    A GOAT emerges, to claim its throne.
    With prowess unmatched, it scales the height,
    In realms of glory, it takes its flight.
    In games of skill, it reigns supreme,
    The GOAT, a champion in every scheme.
    With grace and power, it dominates,
    In history's annals, it seals its fate.
    Through trials faced and challenges met,
    The GOAT's legacy, we won't forget.
    In every triumph, it leaves its mark,
    A symbol of greatness, shining stark.
    Oh, GOAT, in realms of fame you dwell,
    Your spirit shines, a timeless spell.
    In every field, your legend's told,
    Greatest Of All Time, forever bold.

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

    Please continue publishing new tutorials on other CS courses like OS and etc. You are one of the best teachers i've ever seen.

  • @jagjotsingh2039
    @jagjotsingh2039 5 ปีที่แล้ว +9

    Oakland University Sent Me Here

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

    Kash mere class teacher bhi daa in sir ke jaise padha pate🤔🤗

  • @ParvezAlam-gt6cc
    @ParvezAlam-gt6cc 5 ปีที่แล้ว

    Sir you are awesome and teaching style is very good. Thanks for this video Sir. Now I can easily understand everything things about algorithm. Again thank you sir. May you live long and healthy.

  • @all-roundersanyal4472
    @all-roundersanyal4472 4 ปีที่แล้ว

    Sir ,,,you are great ,I love the way you teach. It is so clear.Thanks a lot sir.NPTEL teachers are so boring ,,,,,,but you are interesting with your subject.

  • @AbdallahSayed-hp4hw
    @AbdallahSayed-hp4hw ปีที่แล้ว +1

    thank you very much you help me to understand this, you are a legend

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

    the best explanation ever. Thank you!

  • @zainrizvi6890
    @zainrizvi6890 7 หลายเดือนก่อน +1

    why is the for loop n+1 time at 1:06

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

    We can ignore n+1 in for loop and add n in for loop derive the value like T(n)=T(n-1)+n check 2:30 mins

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

    Your explanation is crystal clear, thanks a lot Sir for sharing your knowledge

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

    God bless you! you made my life easy!!!!!

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

    Hello sir, T(0) would take "1" time, right? not "0" because the program still checks if 0 > 0 at the if-statement. at 6:00

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

    Thank you very much. You are a genius.

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

    Sir your lectures are very helpful for us.
    Thank you sir

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

      Roshni sharma nhạc hen ha chenhacchepp

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

    Why the kth equation is being taken like (n+1)+n???
    Like we r already taking (n-(k-2)) then why??

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

    Sir please....upload a video on PROPERTIES OF ASYMPTOTIC NOTATIONS and how they are used....lately i have beem getting confused on that topic...sir please it will be very helpful for us in GATE examination.

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

    9:14 - Important note (why you should avoid adding expression)

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

    Hello Sir,
    Please recommend books or resources form where we can get exercises to solve these time related problems.
    Thanks.

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

    ENLIGHTENING 🙏💯🔥

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

    Good to the the point lectures with such simplicity and examples... Amazing. may ALLAH bless you.

  • @DavidLopez-eb5km
    @DavidLopez-eb5km 2 ปีที่แล้ว

    Nicely Explained Professor!

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

    You considered the time taken by if statement in this function but you dud not consider the time taken by if statement in the previous lecture. Why is that so?

  • @arnoc.2107
    @arnoc.2107 5 ปีที่แล้ว +1

    love the random stares into the camera like at 8:48 :P

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

    Thank you so much sir you have helped me alot

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

    thanks sir ur videos are so good really understood the concept

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

    Best lectures on Algorithms.

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

    Ok king I see you with the Tommy Hilfiger on 😍

  • @Rob-J-BJJ
    @Rob-J-BJJ 2 ปีที่แล้ว

    can someone explain at 6:10 how does 1 + 2 +... + n - 1 + n = n(n+1)/2 // i understand the left side but i dont understand how he got the right side

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

    15:00 why do we divide it by 2

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

    in the last video you ignored the time for condition check,but now it is included.Why?
    And how the time for the condition check will be one,I thing it have to be checked in all calls of the function.

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

    Life Saver.....
    Thank you Sir.

  • @Ravi-jp3lu
    @Ravi-jp3lu 5 ปีที่แล้ว +1

    sir can we construct recurrence tree for the given recurrence relation without algorithm(void test(n))??

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

    thank you so much for posting this and all you clips. I found them very useful.

  • @meryi.romerofernandez3253
    @meryi.romerofernandez3253 4 ปีที่แล้ว

    muy buena explicación, ahora estoy suscrita..........

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

    you're really good at teaching

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

    you are teaching in nice way

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

    Thanks Abdul Bari!

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

    You are amazing my friend a huge thank you!

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

    Mashallah... ❤❤❤

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

    Sir please upload more videos about data structures sir it is very useful

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

    God bless you sir... you are a great teacher...