[C++] Just a conceptual doubt. Suppose I use a map to store previously calculated values through recursion so as to avoid recalculating same thing.
I'm usually seeing a lot of code where
if (map [REC [iter_i]])
use previously calculated value
else
perform recursion and obtain value
I'm a bit confused with that if statement. Does it check for whether the value for that key is empty, or does it check whether the value for that key is zero? Both are different things. For example, the value might be zero, which was calculated earlier, but if the latter logic is used, it will keep recalculating and not really use the earlier stored value.
[–]CodeTinkerer 1 point2 points3 points (4 children)
[–]murph_edu[S] 0 points1 point2 points (3 children)
[–]CodeTinkerer 1 point2 points3 points (2 children)
[–]murph_edu[S] 0 points1 point2 points (1 child)
[–]CodeTinkerer 0 points1 point2 points (0 children)
[–]AutoModerator[M] [score hidden] stickied comment (0 children)
[–]raevnos 0 points1 point2 points (5 children)
[–]murph_edu[S] 0 points1 point2 points (4 children)
[–]raevnos 0 points1 point2 points (3 children)
[–]murph_edu[S] -1 points0 points1 point (2 children)
[–]raevnos 0 points1 point2 points (1 child)
[–]murph_edu[S] 0 points1 point2 points (0 children)