Tail Call Optimization

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

КОМЕНТАРІ • 42

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

    This is near enough the only effective introduction to this topic on the internet. Thank you!

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

      Hello and thank you very much for your comment! Very happy to be of help :)

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

    Most underrated programming channel I have come across so far! Super clear explanations -- thank you!

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

      Hello and thank you so much for your comment! Glad you like the video and the rest of my work =)

  • @包軟體工程之路
    @包軟體工程之路 7 місяців тому +2

    This is the only video I found that best explain the topic!!!
    Thx A LOT

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

      Hello and thank you very much for your comment and for the super thanks! Very happy to have been of help =)

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

    Thank you veeeery much for this video!!!! I’ve been seraching all this stuff anywhere, but only your video was that best one which could explain what I wanted exactly. Such a short but very meaningful video, excellent, thank you again:)

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

      You're welcome! Very happy to be of help :)

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

    Unsung YT hero! ✨You're a legend, mate! 👑 One of my favourite videos of yours: Priceless for anyone interested in optimization as long as TCO is implemented in your programming language of choice.

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

      Hello and thank you very much for your comment! Glad you liked the video =)

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

    Great explanation - thank you very much.

    • @NERDfirst
      @NERDfirst  6 місяців тому +1

      You're welcome! Very happy to be of help :)

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

    excellent - Interesting. A good teacher with a good understanding of the topic. Never heard of it but now fully understood.

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

      Hello and thank you very much for your comment! Glad you liked the video =)

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

    That`s the best explanation on the subject i`ve seen so far. I was watching a couple of videos and yours have the best bottom-up explanation. Only thing i found lacking was some examples with popular recursive functions (like factorial or fibonacci sequence)

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

      Hello and thank you for your comment! Yeah that's a good point. Maybe I can revisit this topic sometime. General patterns and how to convert a regular recursive function into tail recursion bears further explanation.

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

    Bruh. This is a fabulous expiration

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

      Hello and thank you very much for your comment! Glad you liked the video =)

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

    Just saw your vid from 2014 about serialization. Very concise, and direct, and informative. I originally was searching for what pickling is in Python. You made serialization so easy to understand, that I was able to extract the info and relate it to Python pickle function even though you did not even mention it. Excellent job!

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

      Hello and thank you very much for your comment! Glad you liked my work =D

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

    Explanation was very clear. Props to you.

    • @NERDfirst
      @NERDfirst  Рік тому +1

      Hello and thank you very much for your comment! Very happy to be of help =)

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

    Tq for clear explanation.

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

      You're welcome! Very happy to be of help =)

  • @tobyuchiwa
    @tobyuchiwa Місяць тому

    Thanks for the good explanation bro

    • @NERDfirst
      @NERDfirst  Місяць тому

      You're welcome! Glad to be of help =)

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

    Thanks for this awesome content. Great illustrations. Simple is beautiful. All the best. 😊

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

      Hello and thank you very much for your comment! Glad you liked the video =)

  • @MohammadKamran-mo8pj
    @MohammadKamran-mo8pj 2 місяці тому

    Thank you.

    • @NERDfirst
      @NERDfirst  2 місяці тому

      You're welcome! Glad to be of help =)

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

    You are the one. Thank you so much.

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

      You're welcome! Very happy to be of help =)

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

    Thanks for the overview, this is one of those terms I've certainly heard and had a vague familiarity with but this really brought it into focus.
    Given the rising popularity of functional composition I can see why being able to optimize deeply nested calls would be a real boon!

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

      Hello and thank you for your comment! Yes, I was in the same position as you, this seemed vaguely familiar but I never looked into it until recently. And yes, it's only because I was delving into functional programming!

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

    Great video. So, if a recursive function is tc optimized, does that mean that stack allocated memory for the function is only allocated once (and reused for all recursive calls)?

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

      Hello and thank you for your comment! This may be implementation-dependent, but yes, that's the idea - Either repeatedly reuse or construct and destroy one call stack entry - As long as the entries don't stack up and "wait" for each other, you'll reap the benefits of the tail call.

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

    What would the memory complexity be?

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

      Hello and thank you for your comment! This one is not so easy to discuss in a vacuum, without knowing what code was written in the function(s) involved. Having said that, the short answer is - The memory usage should be similar to if the program was written as iteration, using loops.
      For certain algorithms that, say, pass arrays around and duplicate them for each recursive call, this could mean space complexity improvements from O(n) or more to O(1), while certain algorithms may not have any space complexity benefits at all.

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

    Still unclear to me why you wouldn't have 25 call stacks in memory if you did recursion 25 times..I guess they are just clearing out local variables and the call stack early, is that it?

    • @NERDfirst
      @NERDfirst  Рік тому +1

      Hello and thank you for your comment! Assuming that tail call _optimization_ is indeed happening, then yes, the call stack entries can be overwritten or deleted once each instance of the function has finished running. You only need to keep track of how to return to the original code that called the function.

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

    what software do you use to make your animations/powerpoint slides?

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

      Hello and thank you for your comment! All animations in this video were made in PowerPoint.