动态规划中记忆递归和table方法的时间复杂度比较

Time Complexity comparision of memoized recursion and table method in Dynamic programming

动态规划的每个代码在table方法或记忆递归方法中是否具有相同的时间复杂度?

将不胜感激带有适当示例的解决方案。

时间复杂度- 是(如果忽略 Memoization 中的函数 calls/returns)
Space 复杂性 - 否。制表可以通过覆盖以前计算但不再需要的值来节省 space。

如本答案的“最优性”部分所述-

Either approach may not be time-optimal if the order you happen (or try to) visit subproblems is not optimal, specifically if there is more than one way to calculate a subproblem (normally caching would resolve this, but it's theoretically possible that caching might not in some exotic cases). Memoization will usually add on your time-complexity to your space-complexity (e.g. with tabulation you have more liberty to throw away calculations, like using tabulation with Fib lets you use O(1) space, but memoization with Fib uses O(N) stack space).

进一步阅读- https://www.geeksforgeeks.org/tabulation-vs-memoization/