前言:最近快到FDS考试了,po重刷了一下学校的题目,自己整理了一些解析orz 因为po在自己找解析和学习的过程中非常痛苦,所以在此共享一下我的题目和自己写的解题思路,欢迎各位指出错误~全章节预计会陆续更新,可在专栏查看~
HW1
1. The major task of algorithm analysis is to analyze the time complexity and the space complexity.
T
2. The Fibonacci number sequence {FN} is defined as: F0=0, F1=1, FN=FN−1+FN−2, N=2, 3, .... The time complexity of the function which calculates F(N) recursively is Θ(N!).
F 时间复杂度应该是O(2^N),而N!比2^N还要大。
3. O(N^2) is the same as O(1+2+3+⋯+N).
T 计算sum(1+2+...+N) = (1 + N) * N / 2,去掉常数部分之后可发现 O(1+2+..+N)也为O(N^2)
4. n^0.01 is O(logn).
F n的多少次方最后都比logn大
5. For the following piece of code
if ( A > B ){
for ( i=0; i<N*2; i++ )
for ( j=N*N; j>i; j-- ) &nb