(20 points) Prove, calculate or rank the asymptotic bounds for the following functions.
(a) (10 points) Given the n-th harmonic number \(H(n)\):
\(H(n)=\sum_{k=1}^{n}1/k\quad(n\gt0)\),
prove \(H(n)=O(\log n)\) and \(H(n)=\Omega(\log n)\).
(b) (5 points) Give the asymptotically tight bound (\(\theta\)-notation) for the recurrence \(T(n)\):
\(T(n)=2T(n/2)+n/\log n\quad(\text{assume }T(1)=1)\).
Show the derivation.
(c) (5 points) Rank the following functions \(f_1\ldots f_5\) by order of growth. If \(f_i=O(f_j)\) (\(i\ne j\)), then \(f_i\prec f_j\).
\(f_1=\log^2n\), \(f_2=n\log n\), \(f_3=\sqrt n\), \(f_4=\log(n!)\), \(f_5=(3/2)^n\).
Please complete the form: ___ \(\prec\) ___ \(\prec\) ___ \(\prec\) ___ \(\prec\) ___.
(a) \(1/x\) 遞減,用積分夾 \(H(n)\)
上界:\(\dfrac1k\le\displaystyle\int_{k-1}^{k}\dfrac{dx}x\ (k\ge2)\) → \(H(n)\le1+\displaystyle\int_1^n\dfrac{dx}x=1+\ln n\)
下界:\(\dfrac1k\ge\displaystyle\int_{k}^{k+1}\dfrac{dx}x\) → \(H(n)\ge\displaystyle\int_1^{n+1}\dfrac{dx}x=\ln(n+1)\)
\(\ln(n+1)\le H(n)\le1+\ln n\)
\(H(n)=O(\log n)\),\(H(n)=\Omega(\log n)\) (\(H(n)=\Theta(\log n)\)) 得證
(b) 展開遞迴樹,第 \(i\) 層 \(2^i\) 個節點,每個 cost \(\dfrac{n/2^i}{\log(n/2^i)}\)
第 \(i\) 層總和 \(=\dfrac{n}{\log n-i}\),\(i=0,1,\ldots,\log n-1\)
\(\displaystyle\sum_{i=0}^{\log n-1}\dfrac n{\log n-i}=n\sum_{j=1}^{\log n}\dfrac1j=n\,H(\log n)=\Theta(n\log\log n)\) (用 (a))
葉子 \(n\cdot T(1)=n\),比 \(n\log\log n\) 小
另解:\(n=2^k\),\(A_k=T(2^k)/2^k\) → \(A_k=A_{k-1}+\dfrac1{k\ln 2}\),\(A_k=\Theta(\log k)\);數值上 \(T(n)/(n\log\log n)\) 隨 \(n\) 變大往 1 靠
\(T(n)=\Theta(n\log\log n)\)
(c) \(\log^2n\) 是 polylog,\(\sqrt n\) 是 polynomial → \(f_1\prec f_3\)
\(\sqrt n\prec n\log n\);\(n\log n\) 是 polynomial,\((3/2)^n\) 是 exponential → \(f_2\prec f_5\)
Stirling:\(\log(n!)=n\log n-n\log e+O(\log n)=\Theta(n\log n)\),所以 \(f_4\) 與 \(f_2\) 同階,\(f_4\le f_2\)
\(f_2=O(f_4)\) 與 \(f_4=O(f_2)\) 都成立,兩者誰在前只差 lower-order 項 \(n\log e\);照 \(f_4\le f_2\) 排
\(f_1\prec f_3\prec f_4\prec f_2\prec f_5\) (\(f_4=\Theta(f_2)\))