标签:style blog color os div log sp 时间 on
Finonacci
T(N) = T(N-1) + T(N-2);
>= 2T(N-2) = O(2^(N/2))
Memorized Dp algorithm
//1,1,2,3,5,8..... Memo = {} fib(n): if n in memo, return memo{n} if n<=2: f =1 else: f = fib(n-1) + fib(n-2) memo[n] = f return f.
constant time.
memoized calls cost O(1)
nonmeoized calls cost O(n)
标签:style blog color os div log sp 时间 on
原文地址:http://www.cnblogs.com/leetcode/p/3940705.html