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
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.
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
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.