• Match!!
    link
    fedilink
    English
    arrow-up
    3
    arrow-down
    1
    ·
    1 year ago

    Whenever possible, you should build up a cache dynamically (approaching the desired answer step by step) instead of using recursion, which typically has no answer until it reaches the terminal state and thereby has to propagate all the way down and then propagate back up

    • xmunk@sh.itjust.works
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      This is only particularly relevant for recursive algorithms with multiple dependencies (I.e. our old favorite the fibonocci sequence).

      That is unless you’re talking about really big problems where you’d want to persist the state to disk as you go so you can resume computation if you, for instance, suffer a power outage while computing step 3,198,217 out of 3,198,218.