斐波那契递归

F(n) = F(n-1) + F(n-2)

1
2
3
4
def fib(n):
if n==0 or n==1:
return n
return fib(n-1) + fib(n-2)

时间复杂度2^n

主定律

算法 时间
二分查找 O(logn)
二叉树遍历 O(n)
快速排序/归并排序 O(nlog(n))

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×