算法导论

题目1

*证明若f(n)和g(n)是单调递增的函数,则f(n)+g(n)和f(g(n))也是递增的函数。此外,若f(n)和g(n)是非负的,则f(n)g(n)是单调递增的

证明 :

  • 不妨假设 n 1 ,n 2 是在函数的定义域内,且 n 1 < n 2

因为 f(n)和 g(n)都是单调递增的,则有 f(n 1) < f(n 2) g(n 1) < g(n 2)

令 T n = f(n) + g(n)

则 T n2 -T n1 = f(n 2) - f(n 1) + g(n 2) - g(n 1) > 0

即 T n2 > T n1

所以 T n 是单调递增的,也即是 f(n)+g(n)是递增的;

而 f(g(n))的证法相同,就不再赘述 <外增内增,复合为增 >

  • 假设变量 m,n在函数定义域内,且 m > n,因为递增,则 f(m) > f(n),g(m) > g(n),则 :
    f ( m ) / f ( n ) > 1 , g ( m ) / g ( n ) > 1 f(m)/f(n) > 1,g(m)/g(n) > 1 f(m)/f(n)>1g(m)/g(n)>1

∴ [ f ( m ) ∗ g ( m ) ] / [ f ( n ) ∗ g ( n ) ] > 1 ∴ [f(m)*g(m)]/[f(n)*g(n)] > 1 [f(m)g(m)]/[f(n)g(n)]>1

∴ f ( n ) ∗ g ( n ) 是 单 调 递 增 的 ∴ f(n)*g(n)是单调递增的 f(n)g(n)

题目2

证明等式n!=o(nn), n!=w(2n), lg(n!)=θ(n lgn)。并证明n!=w(2n) 和n!=o(nn)。

​ 证:根据斯特林公式,n!=((2πn)(1/2))*((n/e)n)(1+θ(1/n)),存在任意的正常数c>0,n 0>0,当n 0->正无穷, ((2πn)(1/2))*((1/e)n)(1+θ(1/n)) >0,显然有 0 <= ((2πn)(1/2))*((n/e)n^)*(1+θ(1/n)) <= c (n n),得证 ;

假设要存在任意的正常数c>0,n 0>0,当n>n 0,有 0 <= c 2 n < n!成立,则 n!/(2^n) =((2πn)^(1/2))((n/(2 e))^n)(1+θ(1/n)),显然n 0->无穷,n!/(2 n)->无穷,得证。

​ 同理,假设存在正常数c 1>0,c 2>0,n 0>0,当n>n 0,有c1nlgn< lg(n!) < c 2 nlgn。即当n 0->,则n!=lg(((2πn)(1/2))*((n/e)n))(1+θ(1/n)))/(nlgn) >1,则可知必然存在c 1、c 2,有c 1 <= 1 <=c 2,得证。

题目3

  • ∑ i = 0 d a i ∗ x n = a d ∗ n d + a d − 1 ∗ n d − 1 + a d − 2 ∗ n d − 2 + a d − 3 ∗ n d − 3 + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ + a 1 ∗ n + a 0 < = c ∗ n k \sum_{i=0}^d ai*x^n = a_d*n^d + a_{d-1}*n^{d-1} + a_{d-2}*n^{d-2} + a_{d-3}*n^{d-3} + ······+a_1*n+a_0 <=c*n^k i=0daixn=adnd+ad1nd1+ad2nd2+ad3nd3++a1n+a0<=cnk

    则有
    a d + a d − 1 n + a d − 2 n 2 + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ + a 0 n d < = c n k a_d+\frac{a_{d-1}}{n}+\frac{a_{d-2}}{n^2}+······+\frac{a_0}{n^d}<=cn^k ad+nad1+n2ad2++nda0<=cnk
    令 c = d + 1

    只要:
    n 0 = m a x ( a d k − d , a d − 1 k − d − 1 , ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ , a k 0 ) n_0 = max(\sqrt[k-d]{a_d},\sqrt[k-d-1]{a_{d-1}},······,\sqrt[k]a_0) n0=max(kdad kd1ad1 ka 0)
    即有 p(n) = O(n k)

  • 0 < = c n k = a d ∗ n d + a d − 1 ∗ n d − 1 + a d − 2 ∗ n d − 2 + a d − 3 ∗ n d − 3 + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ + a 1 ∗ n + a 0 0 <= cn^k = a_d*n^d + a_{d-1}*n^{d-1} + a_{d-2}*n^{d-2} + a_{d-3}*n^{d-3} + ······+a_1*n+a_0 0<=cnk=adnd+ad1nd1+ad2nd2+ad3nd3++a1n+a0

    c < = a d + a d − 1 n d − k + a d − 2 n d − k − 1 + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ + a 1 n 1 − k + a 0 n − k c <= a_d + a_{d-1}n^{d-k}+a_{d-2}n^{d-k-1}+······+a_1n^{1-k}+a_0n^{-k} c<=ad+ad1ndk+ad2ndk1++a1n1k+a0nk

    d >= k
    ( 后 者 ) m i n = a d + a d − 1 n d − k + a d − 2 n d − k − 1 + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ + a 1 n 1 − k + a 0 n − k < 1 (后者)_{min} = a_d +a_{d-1}n^{d-k}+a_{d-2}n^{d-k-1}+······+a_1n^{1-k}+a_0n^{-k} < 1 min=ad+ad1ndk+ad2ndk1++a1n1k+a0nk<1
    故 c = a d -1时

    满足第二个条件 p(n) = Ω(n k)

  • 0 < = c 1 n k = a d ∗ n d + a d − 1 ∗ n d − 1 + a d − 2 ∗ n d − 2 + a d − 3 ∗ n d − 3 + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ + a 1 ∗ n + a 0 < = c 2 n k 0 <= c_1n^k = a_d*n^d + a_{d-1}*n^{d-1} + a_{d-2}*n^{d-2} + a_{d-3}*n^{d-3} + ······+a_1*n+a_0 <= c_2n^k 0<=c1nk=adnd+ad1nd1+ad2nd2+ad3nd3++a1n+a0<=c2nk

    因为 k = d

    所以
    c 1 < = a d + a d − 1 n d − k + a d − 2 n d − k − 1 + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ + a 1 n 1 − k + a 0 n − k < c 2 c_1 <= a_d +a_{d-1}n^{d-k}+a_{d-2}n^{d-k-1}+······+a_1n^{1-k}+a_0n^{-k} < c_2 c1<=ad+ad1ndk+ad2ndk1++a1n1k+a0nk<c2
    当c 1 = a d -1,c 2 = a 0 +d
    n 0 = m a x ( a d k − d , a d − 1 k − d − 1 , ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ , a k 0 ) n_0 = max(\sqrt[k-d]{a_d},\sqrt[k-d-1]{a_{d-1}},······,\sqrt[k]a_0) n0=max(kdad kd1ad1 ka 0)
    得到 p(n) = θ(n k

  • 0 < = a d ∗ n d + a d − 1 ∗ n d − 1 + a d − 2 ∗ n d − 2 + a d − 3 ∗ n d − 3 + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ + a 1 ∗ n + a 0 < = c n k 0 <= a_d*n^d + a_{d-1}*n^{d-1} + a_{d-2}*n^{d-2} + a_{d-3}*n^{d-3} + ······+a_1*n+a_0 <= cn^{k} 0<=adnd+ad1nd1+ad2nd2+ad3nd3++a1n+a0<=cnk

    a d + a d − 1 n + a d − 2 n 2 + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ + n 0 n d < = c n k − d a_d + \frac{a_{d-1}}{n}+\frac{a_{d-2}}{n^2}+······+\frac{n_0}{n_d} <= cn^{k-d} ad+nad1+n2ad2++ndn0<=cnkd

    因为 k > d

    则有当 n → ∞ 时

    对于任意的c > 0都成立,故有 p(n) = o(n k)

  • 0 < = c n k = a d ∗ n d + a d − 1 ∗ n d − 1 + a d − 2 ∗ n d − 2 + a d − 3 ∗ n d − 3 + ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ + a 1 ∗ n + a 0 0 <= cn^k = a_d*n^d + a_{d-1}*n^{d-1} + a_{d-2}*n^{d-2} + a_{d-3}*n^{d-3} + ······+a_1*n+a_0 0<=cnk=adnd+ad1nd1+ad2nd2+ad3nd3++a1n+a0

    c < = a d n + ⋯ + a i + a i − 2 n k − i + ⋯ + n 0 n k c <= a_dn+\cdots+a_i+\frac{a_{i-2}}{n^{k-i}}+\cdots+\frac{n_0}{n^k} c<=adn++ai+nkiai2++nkn0

    n比较大时
    c < = a d n + ⋯ + a i + a i − 2 n k − i + ⋯ + n 0 n k c <= a_dn+\cdots+a_i+\frac{a_{i-2}}{n^{k-i}}+\cdots+\frac{n_0}{n^k} c<=adn++ai+nkiai2++nkn0
    此时满足 p(n) = w(n k)

你可能感兴趣的:(算法)