Data Structures Using C++: Illustration of Recursive Function Calls (Call Stack)

Sdílet
Vložit
  • čas přidán 3. 08. 2012
  • Concepts:
    What happens in memory on each recursive function call?
    Illustration of the individual stack frames on the call stack

Komentáře • 110

  • @navidgol5786
    @navidgol5786 Před 9 lety +42

    I don't know why our teacher wants to complicate everything! thank's man that was an awesome video!

  • @yazadbhathena672
    @yazadbhathena672 Před 10 lety +5

    The only person on the internet who actually explains this well
    and no, I'm not exaggerating.

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

    I was very confused, but today my confusion get a medecine. Long life to you Sir. I subscribe right now!

  • @michaeldunleavy326
    @michaeldunleavy326 Před 8 lety +16

    well, that was the best explanation of recursion I've seen. thanks a lot :-)

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

    No complications. Just concept. Thanks man. Really helpful.

  • @nehemiahadeosun5585
    @nehemiahadeosun5585 Před 9 lety +3

    Thank you very much, you've saved a soul today.You are blessed...

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

    This is such a good explanation on a tough topic. Thanks for helping me finally get it !

  • @Ghost-nz4fx
    @Ghost-nz4fx Před 2 lety

    It's the best explanation ever! A simple explanation and straight to the point. Thank you so much.

  • @annafebland4460
    @annafebland4460 Před 7 měsíci

    Thank you thank you! May God bless and protect you and your family ❤

  • @ambujsingh4406
    @ambujsingh4406 Před 2 lety +2

    I made many programs in java and c and was debugging them with breakpoint to understand how it works and saw many videos wasn't satisfied but in SoloLearn someone had given your video link i don't click on links normally but i had no options either so i wanted to take a chance.
    And now i understand it how it works thanks man Liked and Subscribed your channel ❤️

  • @SidonDuarte
    @SidonDuarte Před 2 lety

    Really! The best explanation.

  • @siphiwekarimakwenda9313

    The perfect recursion tutorial!!!!

  • @SpawnEmdee
    @SpawnEmdee Před 4 lety

    Thank you! I was having headache understanding recursion. your explanation is the best!!

  • @underrated_mono9770
    @underrated_mono9770 Před 2 lety

    I still love this video because intuitive and concise.
    great video!

  • @abdullahsorathia3394
    @abdullahsorathia3394 Před 11 lety

    Thanks a lot clarifying my doubts.You teach Like a Pro..

  • @petruciucur
    @petruciucur Před 7 lety

    Very simple and concise. Thanks !

  • @pipebomb8562
    @pipebomb8562 Před 6 lety

    fantastic explanation. Impressed

  • @dfla5472
    @dfla5472 Před 3 lety

    THANKS !! Precise and simple explanation.

  • @TheHolyReality
    @TheHolyReality Před 10 lety

    Very well explained , plain , simple and precise.

  • @rawanfouda2291
    @rawanfouda2291 Před 4 lety

    Just what I needed. Thanks a lot!

  • @vickyees
    @vickyees Před 3 lety

    Amazing sir! You made it clear!🙏

  • @richie.edwards
    @richie.edwards Před 10 lety

    Very clear explanation. Thanks.

  • @elephantride8912
    @elephantride8912 Před 8 lety +1

    easy to undersatnd. ..Thanks for ur effort

  • @paulm6084
    @paulm6084 Před 2 lety

    Very clear. Mocked up the video in python. Code:
    def factorial(i,x):
    print("factorial function invoked. Stack frame #",i,"named: fact(",x,")")
    if x == 0:
    print("Base case reached.
    ")
    print("factorial function fact(",x,"), returned value:",1," Stack frame #",i, " popped from the stack.")
    return 1
    else:
    y = x* factorial(i+1,x-1)
    print("factorial function fact(",x,"), returned value:",y," Stack frame #",i, " popped from the stack.")
    i-=1
    if i == 0:
    print("
    Stack is cleared.")
    return y
    factorial(1,4)

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

    amazing explanation. hats off!

  • @Farrukhw
    @Farrukhw Před 6 lety

    Waooo, how simply it gets into my brain.... Thank you very much....

  • @rogueflynn
    @rogueflynn Před 11 lety +1

    Thank you! This really helped my understanding.

  • @nadiahzulkifli3867
    @nadiahzulkifli3867 Před 5 lety

    you help me a lot sir! so nervous for the presentation and after watching this, i know how to explain

  • @SharpSteelz
    @SharpSteelz Před 6 lety

    this was really helpful thanks a lot, didn't understand this for the longest time

  • @gazisalahuddin8681
    @gazisalahuddin8681 Před 5 lety

    a million thanks..keep up the awesome works

  • @MrWardo2009
    @MrWardo2009 Před 3 lety

    Thanks for making this video!

  • @wowzande
    @wowzande Před 6 lety

    good stuff! finally understand recursion! to a certain extent
    much better then what they taught in class!

  • @lego2918
    @lego2918 Před 10 lety

    Great explanation, really helpful, much better than my text book

  • @mehedibd89
    @mehedibd89 Před 6 lety

    Great Explanation! Thanks for your video.

  • @durgapalepu5780
    @durgapalepu5780 Před 10 lety

    I liked the pictorial way of explaining the concept!!

  • @abhishekjha2957
    @abhishekjha2957 Před 4 lety

    This helped me a lot.

  • @sayednaweed745
    @sayednaweed745 Před 5 lety

    Great explanation

  • @SillyPlanet92
    @SillyPlanet92 Před 5 lety

    great explanation. thank you

  • @TamImBlessed
    @TamImBlessed Před 9 lety

    You just saved me, thanks for helping.

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

    Thanks a lot sir, I just understood the whole thing very easily

  • @trixxter3817
    @trixxter3817 Před 4 lety

    Super explanation ❤️

  • @faris899
    @faris899 Před 8 lety +5

    Wish you were my professor

  • @Omioblivion
    @Omioblivion Před 11 lety

    Great video, yet again.

  • @saptarshisahoo5075
    @saptarshisahoo5075 Před 8 lety

    its very helpful. Thank you sir.

  • @sherif4csharp
    @sherif4csharp Před 4 lety

    Thanks for your help

  • @petruciucur
    @petruciucur Před 7 lety +1

    Great ! Thanks a lot !

  • @VihangaHeshan
    @VihangaHeshan Před 11 lety

    Very useful................

  • @NZFoxy
    @NZFoxy Před 3 lety

    Thank you so much!

  • @Darkion45
    @Darkion45 Před 12 lety

    great explanation, thanks!

  • @AlMarufSharif
    @AlMarufSharif Před 9 lety

    Nice explanation!!

  • @mishanshah6827
    @mishanshah6827 Před 5 lety

    Very nice 👌

  • @MiladZohravi
    @MiladZohravi Před 9 lety

    very special thanks

  • @ozzy2361
    @ozzy2361 Před 3 lety

    Thank you so much!!

  • @nasircsedu
    @nasircsedu Před 11 lety

    it's awesome, man

  • @padmanabhmishra9669
    @padmanabhmishra9669 Před 2 lety

    Thank you.

  • @dangerrrman
    @dangerrrman Před 11 lety

    Thanks for clarifying this topic :-)

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

    in order to make this video more complete, local variables and the logic usage of these variables are needed. it is not just the arguments that need to be traced but the local variables are very crucial in order to trace the recursion.

  • @sharphon
    @sharphon Před 10 lety +1

    Great explained. Now it's clear why recursive functions are dangerous :D

  • @Malak_95y
    @Malak_95y Před 8 lety

    thank you so much

  • @BharatChandak1
    @BharatChandak1 Před 11 lety

    awesome explanation :)

  • @djavadovjavoxir2248
    @djavadovjavoxir2248 Před 3 lety

    thank u bro good luck your life!

  • @supreethavadhani8916
    @supreethavadhani8916 Před 7 lety

    helped a lot!

  • @kirolosyassa5798
    @kirolosyassa5798 Před 4 lety

    it was so helpful :)

  • @sunflower20505
    @sunflower20505 Před 9 lety

    thank you.

  • @mlungisinkomo2382
    @mlungisinkomo2382 Před 3 měsíci

    well............ this makes sense 😊thanks man

  • @muhammadawaisbhatti942

    Thank you for the explanation of states of program execution stack during recursion. However, i think what you missed is, focus on control, you forget to tell how control will shift from first recursion call to second recursion call and how did the control will return back for every recursive call.

  • @apurvatiwari2
    @apurvatiwari2 Před 11 lety

    Thanks a lot mate!!!!!!

  • @harshitpatnaik6381
    @harshitpatnaik6381 Před 6 lety

    Thank you vry much

  • @ManishKumar-kc1cn
    @ManishKumar-kc1cn Před rokem

    Thanks sir

  • @ghostinthedarkness30
    @ghostinthedarkness30 Před 9 lety

    thank you!!!

  • @noreplywiggle42
    @noreplywiggle42 Před rokem

    nice man

  • @ashok845
    @ashok845 Před 11 lety

    Well explained! Can you please explain merge sort using recursion in the same manner.

  • @unplugged406
    @unplugged406 Před 7 lety

    God bless you son

  • @logeshs9370
    @logeshs9370 Před 6 lety

    nice expl

  • @michaelcollins4325
    @michaelcollins4325 Před 7 lety

    once again, your videos save my ass; you always explain it better than my professors :D, thanks!

  • @DavidSprings
    @DavidSprings Před 10 lety

    Great way to create deep subdirectories on a drive. Really, really deep. Trust me.

    • @DavidSprings
      @DavidSprings Před 10 lety

      Patrick Davis I ended up creating subdirectories within subdirectories until either Windows crashed or the drive filled up.

  • @petesandwich3246
    @petesandwich3246 Před 9 lety

    Would iterative function utilize less memory since it essentially increments a variable rather than creating N stacks?

  • @LuaneCarolineAquinoCavalcanti

    thanks a lot

  • @jorgetadeo510
    @jorgetadeo510 Před 5 lety

    What would be the run time and space complexity of this?

  • @kazenohito7641
    @kazenohito7641 Před 8 lety

    Jesus christ I hate my school. After watching your video I googled and then read the chapters in my book about stacks and queues and not recursion makes so much more sense. I don't get why my university thinks its ok to try to make us write programs recursively without an understanding of what actually happens with your data.

    • @zoranjovanov8564
      @zoranjovanov8564 Před 8 lety +1

      u have to look up on ur own.

    • @kazenohito7641
      @kazenohito7641 Před 8 lety

      Yeah I know.... That's how I got here. Thank you captain obvious.

    • @zoranjovanov8564
      @zoranjovanov8564 Před 8 lety +1

      haha that was not the point :d wanted to say school only gives u the very basics and the rest is up to us:P

    • @meditationkaiinsaf5505
      @meditationkaiinsaf5505 Před 3 lety

      @@zoranjovanov8564 thank you

  • @onealoneal7047
    @onealoneal7047 Před 2 lety

    For the if\else structure you don’t have to use curly braces if you only have single instruction to write

  • @Richard-yz2gy
    @Richard-yz2gy Před 4 měsíci

    hi there what happens if a value is not getting returned to the previous stack frame??

  • @SearchingPeaceInside
    @SearchingPeaceInside Před 7 lety

    What happens to rbp, rsp in assembly

  • @hortinus
    @hortinus Před 4 lety

    What if n

  • @kashif2309
    @kashif2309 Před 5 lety

    how come num equals to n in the factorial function?

  • @sarahlakehal3378
    @sarahlakehal3378 Před 3 lety

    lol watching this 3 hours before my exam

  • @MegaCooloman
    @MegaCooloman Před 6 lety

    Could we have chosen n == 1 as a base case? seems like it would work but is it bad design?
    Pardon my bad English !!

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

      Sorry for the late reply; you may have already found the answer to your question. You can technically get the same result with a base case of (n==1), but it makes more mathematical sense to make it (n==0), because the factorial of 0 is 1.

    • @meditationkaiinsaf5505
      @meditationkaiinsaf5505 Před 3 lety

      @@GrandofTheftHero Thanks for clear me.

  • @artteaparty
    @artteaparty Před 8 lety

    That's a great video, just I have a problem. Sometimes in some program it happens that the result of Recursive Function comes backward. You know, like instead of printing 1 2 3 ..., prints 3 2 1. Can you give some hints?

    • @Kalo953
      @Kalo953 Před 8 lety

      +sasa february in order to understand why it happens you need to understand the call stack and what happens when you have statements after the recursive call of the function.

    • @meditationkaiinsaf5505
      @meditationkaiinsaf5505 Před 3 lety

      Cause, Stack follows FIFO (First In First OUT).Thank you

  • @Strategic.
    @Strategic. Před 3 lety

    Dude you still alive? Have you built anything amazing so far?

  • @Icecube88
    @Icecube88 Před 5 lety

    first one in, last one out.

  • @ilayasaravanan
    @ilayasaravanan Před 2 lety

    Amazing video mate. Helped understand recursion. Until I saw this illustration, I have to say, my grasp of recursion was dodgy.

  • @pixelnetwork1430
    @pixelnetwork1430 Před 10 lety

    Looks like 4x Fart (3)