1. 斐波那契数列
public class Main {
public static void main(String[] args) {
System.out.println(fib2(70));
}
/**
* 0 1 1 2 3 5 8 13
*/
public static int fib1(int n){
if(n<=1)
return n;
return fib1(n-1)+fib1(n-2);
}
public static int fib2(int n){
if(n<=1)
return n;
int first = 0;
int second = 1;
for(int i=0;i<n-1;i++){
int sum = first+second;
first = second;
second = sum;
}
return second;
}
}
2. 大O表示法
3. 线性表
来源:CSDN
作者:茶花女-
链接:https://blog.csdn.net/qq_42764468/article/details/104056059