Lecture Note - 北大 - 算法设计与分析 Design and Analysis of Algorithms - Wanling Qu
2015-03-28 18:43
706 查看
第一周作业
Question 7
下表给出 5 组 f(n) f(n) 和 g(n) g(n) 函数12345f(n)2n3+3n50n+logn50nlognlognn!g(n)100n2+2n+10010n+loglogn10nloglognlog2n5n\begin{equation}
\begin{split}
& \quad f(n) & \quad g(n) \\
1 & \quad 2 n^3 + 3n & \quad 100 n^2 + 2n + 100 \\
2 & \quad 50 n + \log n & \quad 10 n + \log \log n \\
3 & \quad 50 n \log n & \quad 10 n \log \log n \\
4 & \quad \log n & \quad \log^2 n \\
5 & \quad n! & \quad 5^n
\end{split}
\end{equation}
使得 f(n)=O(g(n)) f(n) = O (g(n)) 成立的组号(从小到大排列)是:
24
Question 8
使得 f(n)=Ω(g(n)) f(n)=\Omega(g(n)) 成立的组号从小到大排列是(格式同上一题):1235
Question 10
使得 f(n)=Θ(g(n)) f(n)=\Theta(g(n)) 成立的组号从小到大排列是(格式同上一题):2
Slide - 011序列求和的方法
调和级数
调和级数(英语:Harmonic series)是一个发散的无穷级数,表达式为:∑k=1∞1k=1+12+13+14+⋯ \sum_{k=1}^{\infty} \frac{1}{k} = 1 + \frac12 + \frac13 + \frac14 + \cdots
第n个调和数与n的自然对数的差值(即 ∑nk=11k−lnn \sum_{k=1}^{n} \frac{1}{k} - \ln n )收敛于欧拉-马歇罗尼常数。
二分检索平均时间复杂度
结点数总共为 n=2k−1 n = 2^k - 1 。在前 k−1 k - 1 次检索成功,有 1 1 个元素第 1 1 次检索成功,有 2 2 个元素第 2 2 次检索成功,有 3 3 个元素第 3 3 次比较成功,依次类推,有 2t−1 2^{t-1} 个元素第 t t 次检索成功。
而在第 k k 次的比较中,有 2k−1 2^{k-1} 个元素可能检索成功,还可能会有 n+1 n + 1 个元素检索不成功。
所以会有 Slide 中所示的计算方法。
第二周作业
Question 1
可用数学归纳法证明:∑k=1nk2=n(n+1)(2n+1)6\begin{equation}
\sum_{k=1}^n k^2 = \frac{n (n+1) (2n+1)}{6}
\end{equation}
Question 2
递推式应该为:T(n)=logn+log(n−1)+log(n−2)+⋯+log1 T(n) = \log n + \log (n-1) + \log (n-2) + \cdots + \log 1
推测 T(n) T(n) 的阶应该是 Θ(nlogn) \Theta (n \log n) 。
Question 3
根据主定理,T(n) T(n) 的阶是 Θ(nlog27) \Theta (n^{\log_2 7}) ,W(n) W(n) 的阶 Θ(nlog4a) \Theta (n^{\log_4 a}) 应该不超过 T(n) T(n) 的阶,即 nlog4a⩽nlog27 n^{\log_4 a} \leqslant n^{\log_2 7} ,可解出最大的 a=48 a = 48 。Question 4
由主定理可知,T(n)=Θ(n2) T(n) = \Theta (n^2)相关文章推荐
- Algorithms: Design and Analysis Note
- Design and Analysis of Algorithms_Brute Froce
- System Analysis and Design in a Changing World(系统分析和设计)
- Design and Analysis of Algorithms_Introduction
- Design and Analysis of Algorithms_Divide-and-Conquer
- Introduction to The Design and Analysis of Algorithms (1)
- Design and Analysis of Algorithms_Decrease-and-Conquer
- Design and Analysis of Algorithms_Fundamentals of the Analysis of Algorithm Efficiency
- Design and Analysis of Distributed Algorithms
- Objected-Oriented Analysis and Design (OOAD 面对对象的分析与设计)
- Object Oriented Analysis and Design Using UML A Whitepaper by Mark Collins-Cope of Ratio Group.
- The design and analysis of high frequency phased array coils for MRI
- Stanford - Algorithms: Design and Analysis, Part 1 - Week 6 Assignment: hash table and heap
- 学习总结: Algorithms: Design and Analysis, Part2
- Stanford - Algorithms: Design and Analysis, Part 1 - Week 4 Assignment: strongly connected component
- note of introduction of Algorithms(Lecture 3 - Part1)
- Stanford - Algorithms: Design and Analysis, Part 1 - Week 3 Assignment: Contraction
- Stanford - Algorithms: Design and Analysis, Part 2 - Week 1 Assignment: Greedy and Prim
- Stanford - Algorithms: Design and Analysis, Part 1 - Week 1 Assignment: number of inversions
- 对System Analysis and Design的课程设计的一些总结