由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - 如何分析 recursive function 的复杂性
相关主题
is there anyway that i can return...菜鸟求助,关于recursive的问题
Alternative way to swap Integerhow to compile java source code recursively in a command line?
Integer in heap问个问题
a fun coding question请问如何在java中寻找文件夹的深度(by recursive)?
出个简单题,看你Java APi熟悉到什么程度问个ArrayList的问题
made a low-level mistakeSplit a String into valid English words
Re: 怎样递归操作目录,子目录以及他们下面的文件?Recusion is fucking magic!!
什么是functionality test?关于Vector的土问题
相关话题的讨论汇总
话题: nth话题: return话题: map话题: int话题: integer
进入Java版参与讨论
1 (共1页)
l******0
发帖数: 244
1
比如分析这两个算法:
int nth(int n){

if(n==0){
return 0;
}
if(n==1){
return 1;
}

return nth(n-1) + nth(n-2);

}
int nth(int n, Map map){

if(n==0){
return 0;
}
if(n==1){
return 1;
}

if( !map.containsKey(n) ){
map.put(n, nth(n-1,map) + nth(n-2,map));
}
return map.get(n);

}
z*********e
发帖数: 10149
2
第一个肯定是2^n吧

【在 l******0 的大作中提到】
: 比如分析这两个算法:
: int nth(int n){
:
: if(n==0){
: return 0;
: }
: if(n==1){
: return 1;
: }
:

1 (共1页)
进入Java版参与讨论
相关主题
关于Vector的土问题出个简单题,看你Java APi熟悉到什么程度
how to run java program in dos?made a low-level mistake
using SQL in JavaRe: 怎样递归操作目录,子目录以及他们下面的文件?
问一个题什么是functionality test?
is there anyway that i can return...菜鸟求助,关于recursive的问题
Alternative way to swap Integerhow to compile java source code recursively in a command line?
Integer in heap问个问题
a fun coding question请问如何在java中寻找文件夹的深度(by recursive)?
相关话题的讨论汇总
话题: nth话题: return话题: map话题: int话题: integer