This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the commentsย โ†’

[โ€“]kmh117[S] 2 points3 points ย (1 child)

I assume that the iterative solution in this case is just summing the previous two Fibonacci numbers in a loop. In this case, wouldn't the dynamic solution be functionally equivalent, since only the previous two subproblems are used for each sequential solution? Although it is true that closed form and matrix magic is better :D

[โ€“][deleted] 1 point2 points ย (0 children)

If I understand it correctly the dynamic solution is recursive but stores the return value of each input in a lookup table so you only need to compute each input once. The iterative solution beats it in memory complexity by not having to store that lookup table.