What are Tail-Recursive Methods? | Tail-Recursion Made Simple | Tail-Call Optimization | Geekific

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

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

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

    I kid you not, what you did in 6 minutes is more effective than a 50 minute class I just took. I'm a North American university, btw.

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

    The description, the transformations, the visualization WOW!
    Glad I found this gem of a channel, life will be simpler now :)

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

      Thanks a lot for your support! Am very glad the video was helpful :)

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

    Love computer science, there are so many interesting concepts to learn.

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

    Helpful and straight to the point , thanks !

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

    take home
    Continuation passing style might be the only generic way out there that allows you to transform any code into a form that uses only tail calls hence reducing space complexity of recursive calls from O(n) to O(1)

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

    2:49 to rephrase the given code:
    factorial(n) = factorial(n, 1)
    factorial(1, x) = x
    factorial(n, x) = factorial(n - 1, n * x)
    as compared to simple:
    factorial(1) = 1
    factorial(n) = n * factorial(n - 1)
    hahaha, that's basically encoding the looping variables inside the function call itself.
    this is exaclty what:
    * i inferred while trying to write binomial coefficients recurcively, and later
    * an article said about tail rec: "it's effectively using fxn calls to implicitly control the repetitions, rather than using explicit loops"

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

      this is basically like creating an interface - which seems good on outside but in internal inolementation, the structure of the problem at hand is butchered.
      which is one of the key selling pt of recursion: easily replicate the problem structure.
      but yeah, other benefits to recursion still exists: its functional & stateless nature.

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

    Excellent. Just what I needed

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

      Glad it is :)

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

    Woo finally video after 1 week 😅

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

      Well yeah, I work full-time, so I upload once a week at the same time (banner has the timings)... Sorry can't upload more atm 😥

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

    Tail recursion doesn't work in javascript, in fact trying it on a simple factorial example it would blow up the stack faster than just recursion. Not all languages support this kind of optimisation, or they perform it by default and you just don't realise so it looks like no optimisation happened.
    I'm sitting here having to reinvent recursion to move it off the stack and onto the heap, I've only had one hour to do it and so far it works better (I can do 10^7 recursions just fine) untill I run out of heap size. It's partially fixable by flagging my nodejs script to run with a bigger heap size but ram is not infinite, I will find a more compact solution eventually.

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

    I am very thankful!

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

      Thank you! Glad I could help :)

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

    Thank you so much. Very helpful :)

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

      Glad it was helpful :)

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

    Need multithreading playlist

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

    Geek stuff.

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

    ✌👍👍