时间复杂度分析(递归求斐波那契)

使用递归树进行分析   1.斐波那契的递推式是:   f(n)=f(n-1)+f(n-2) 其中:f(1)=1,f(2)=1   2.用java代码实现: public int getResult(int n){ if(n == 1 || n == 2) return 1; return getResult(n-1)+getResult(n-2); } 3.时间复杂度分析(递归树)     递归树
相关文章
相关标签/搜索