【经典阅读】《算法导论》Chapter3 Growth of Functions

【经典阅读】《算法导论》Chapter3 Growth of Functions

1. 知识梳理
  • 渐近记号与定义
    { Θ 、 Ω 、 O 、 o 、 ω } ∼   { = 、 ≥ 、 ≤ 、 < 、 > } \{\Theta 、 \Omega、O、o、\omega \} \sim \ \{=、\ge、\le、\lt、\gt\} {ΘΩOoω} {=<>}

    1. f ( n ) = Θ ( g ( n ) ) → { f ( n ) : t h e r e   e x i s t   p o s i t i v e   c o n s t a n t s   c 1 , c 2   a n d   n 0   s u c h   t h a t   0 ≤ c 1 g ( n ) ≤ f ( n ) ≤ c 2 g ( n )   f o r   a l l   n ≥ n 0 } f(n) = \Theta(g(n)) \rightarrow \{f(n): there \ exist \ positive \ constants \ c_1,c_2 \ and \ n_0 \ such \ that \ 0 \le c_1g(n) \le f(n) \le c_2g(n) \ for\ all \ n \ge n_0 \} f(n)=Θ(g(n)){f(n):there exist positive constants c1,c2 and n0 such that 0c1g(n)f(n)c2g(n) for all nn0}
    2. f ( n ) = Ω ( g ( n ) ) → { f ( n ) : t h e r e   e x i s t   p o s i t i v e   c o n s t a n t s   c   a n d   n 0   s u c h   t h a t   0 ≤ c g ( n ) ≤ f ( n )   f o r   a l l   n ≥ n 0 } f(n) = \Omega(g(n)) \rightarrow \{f(n): there \ exist \ positive \ constants \ c \ and \ n_0 \ such \ that \ 0 \le cg(n) \le f(n) \ for\ all \ n \ge n_0 \} f(n)=Ω(g(n)){f(n):there exist positive constants c and n0 such that 0cg(n)f(n) for all nn0}
    3. f ( n ) = O ( g ( n ) ) → { f ( n ) : t h e r e   e x i s t   p o s i t i v e   c o n s t a n t s   c   a n d   n 0   s u c h   t h a t   0 ≤ f ( n ) ≤ c g ( n )   f o r   a l l   n ≥ n 0 } f(n) = O(g(n)) \rightarrow \{f(n): there \ exist \ positive \ constants \ c \ and \ n_0 \ such \ that \ 0 \le f(n) \le cg(n)\ for\ all \ n \ge n_0 \} f(n)=O(g(n)){f(n):there exist positive constants c and n0 such that 0f(n)cg(n) for all nn0}
    4. f ( n ) = o ( g ( n ) ) → { f ( n ) : f o r   a n y   p o s i t i v e   c o n s t a n t   c > 0 , t h e r e   e x i s t s   a   c o n s t a n t   n 0 > 0   s u c h   t h a t   0 ≤ f ( n ) < c g ( n )   f o r   a l l   n ≥ n 0 } f(n) = o(g(n)) \rightarrow \{f(n): for \ any \ positive \ constant \ c \gt 0,there \ exists \ a \ constant \ n_0\gt 0 \ such \ that \ 0 \le f(n) \lt cg(n)\ for\ all \ n \ge n_0 \} f(n)=o(g(n)){f(n):for any positive constant c>0,there exists a constant n0>0 such that 0f(n)<cg(n) for all nn0}
    5. f ( n ) = ω ( g ( n ) ) → { f ( n ) : f o r   a n y   p o s i t i v e   c o n s t a n t   c > 0 , t h e r e   e x i s t s   a   c o n s t a n t   n 0 > 0   s u c h   t h a t   0 ≤ c g ( n ) < f ( n )   f o r   a l l   n ≥ n 0 } f(n) = \omega(g(n)) \rightarrow \{f(n): for \ any \ positive \ constant \ c \gt 0,there \ exists \ a \ constant \ n_0 \gt 0 \ such \ that \ 0 \le cg(n) \lt f(n) \ for\ all \ n \ge n_0 \} f(n)=ω(g(n)){f(n):for any positive constant c>0,there exists a constant n0>0 such that 0cg(n)<f(n) for all nn0}
  • 记号的性质

    1. 传递性(Transitivity): f ( n ) = Θ ( g ( n ) )   a n d   g ( n ) = Θ ( h ( n ) )    ⟹    f ( n ) = Θ ( h ( n ) ) f(n) =\Theta(g(n)) \ and \ g(n)=\Theta(h(n)) \implies f(n) =\Theta(h(n)) f(n)=Θ(g(n)) and g(n)=Θ(h(n))f(n)=Θ(h(n)),对以上记号均成立
    2. 自反性(Reflexivity): f ( n ) = Θ ( f ( n ) ) f(n) = \Theta(f(n)) f(n)=Θ(f(n)),对 ω 、 o \omega、o ωo不成立
    3. 对称性(Symmetry): f ( n ) = Θ ( g ( n ) )    ⟺    g ( n ) = Θ ( f ( n ) ) f(n) =\Theta(g(n)) \iff g(n) =\Theta(f(n)) f(n)=Θ(g(n))g(n)=Θ(f(n)),只适合 Θ \Theta Θ记号
    4. 转置对称性(Transpose symmetry): f ( n ) = O ( g ( n ) )    ⟺    g ( n ) = Ω ( f ( n ) ) f(n) = O(g(n)) \iff g(n) = \Omega(f(n)) f(n)=O(g(n))g(n)=Ω(f(n)),对于 ω 、 o \omega、o ωo也适用

    不是所有函数都可以渐近比较,即 f ( n ) = O ( g ( n ) ) f(n)=O(g(n)) f(n)=O(g(n))等比较可能不成立, E x : n   a n d   n 1 + s i n   n Ex:n \ and \ n^{1+sin\ n} Exn and n1+sin n

  • 标记记号与常用函数

    1. 一些取整式子(待证明):
      • ⌈ ⌈ x / a ⌉ b ⌉ = ⌈ x a b ⌉ \bm{\lceil \frac{\lceil x/a \rceil}{b}\rceil = \lceil \frac{x}{ab}\rceil} bx/a=abx
      • ⌊ ⌊ x / a ⌋ b ⌋ = ⌊ x a b ⌋ \bm{\lfloor \frac{\lfloor x/a \rfloor}{b}\rfloor = \lfloor \frac{x}{ab}\rfloor} bx/a=abx
      • ⌈ a b ⌉ ≤ a + ( b − 1 ) b \bm{\lceil \frac{a}{b}\rceil \le \frac{a + (b-1)}{b}} baba+(b1)
      • ⌈ a b ⌉ ≥ a − ( b − 1 ) b \bm{\lceil \frac{a}{b}\rceil \ge \frac{a - (b-1)}{b}} baba(b1)
    2. 多项式:若对于某个常量 k k k,有 f ( n ) = O ( n k ) f(n) = O(n^k) f(n)=O(nk),则称 f ( n ) f(n) f(n)多项式有界的。
    3. 指数:当 ∣ x ∣ ≤ 1 |x| \le1 x1时,近似有: 1 + x ≤ e x ≤ 1 + x + x 2 1+x \le e^x \le 1+x+x^2 1+xex1+x+x2
    4. 对数:
      • a l o g b c = c l o g b a a^{log_bc} = c^{log_ba} alogbc=clogba
      • 换底公式;
      • x > − 1 x \gt -1 x>1 x 1 + x ≤ l n ( 1 + x ) ≤ x \frac{x}{1+x} \le ln(1+x) \le x 1+xxln(1+x)x
      • 多对数有界:对于某个常量 k k k f ( n ) = O ( l g k n ) f(n) = O(lg^kn) f(n)=O(lgkn)
    5. 阶乘:
      • 斯特林近似公式 n ! = 2 π n ( n e ) n ( 1 + Θ ( 1 n ) ) n! = \sqrt{2\pi n}(\frac{n}{e})^n(1+\Theta(\frac{1}{n})) n!=2πn (en)n(1+Θ(n1))
    6. 多对数、多项式、指数函数间速率比较: n b = o ( a n )   f o r   a l l   a > 1 n^b = o(a^n) \ for \ all \ a\gt1 nb=o(an) for all a>1 l g b n = o ( n a )   f o r   a l l   a > 0 lg^bn = o(n^a) \ for \ all \ a\gt 0 lgbn=o(na) for all a>0
    7. 多重函数:
      f ( i ) ( x ) = { n if i = 0 f ( f ( i − 1 ) ( n ) ) if i > 0  f^{(i)}(x)= \begin{cases} n &\text{if i = 0}\\ f(f^{(i-1)}(n))&\text{if i$\gt$0 } \end{cases} f(i)(x)={nf(f(i1)(n))if i = 0if i>
    8. 多重对数函数: l g ∗ n = m i n { i ≥ 0 : l g ( i ) n ≤ 1 } lg^*n = min\{i \ge 0: lg^{(i)}n \le 1\} lgn=min{i0:lg(i)n1}
    9. 斐波那契数:
      • 黄金分割率: ϕ = 1 + 5 2 \phi=\frac{1+\sqrt{5}}{2} ϕ=21+5 ,共轭数 ϕ ^ = 1 − 5 2 \hat{\phi} = \frac{1-\sqrt{5}}{2} ϕ^=215
      • F i = ϕ i − ϕ ^ i 5 F_i = \frac{\phi^i - \hat{\phi}^i}{\sqrt{5}} Fi=5 ϕiϕ^i;
      • ∣ ϕ ^ ∣ < 1 → ∣ ϕ ^ ∣ 5 < 1 5 < 1 2 → F i = ⌊ ϕ i 5 + 1 2 ⌋ |\hat{\phi}| \lt1 \rightarrow \frac{|\hat{\phi}|}{\sqrt{5}} \lt \frac{1}{\sqrt{5}} \lt \frac{1}{2} \rightarrow F_i = \lfloor \frac{\phi^i}{\sqrt{5}} + \frac{1}{2} \rfloor ϕ^<15 ϕ^<5 1<21Fi=5 ϕi+21
2. 课堂笔记

主要看递归式求解方法,有些内容(如主方法的证明)在第四章。
在这里插入图片描述
在这里插入图片描述

3. 重点习题

练习题
3.1-2、3.1-3、3.2-3、*3.2-4、*3.2-5
思考题
全部(3-1 → \rightarrow 3-6)

点此链接查看习题与答案

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
目前最全的算法导论第三版的答案 清晰度极好 另每章都有章节重点总结 在第二版基础上新增习题的解答详尽清楚 很适合 用这本经典教材的同学! Contents Revision History R-1 Preface P-1 Chapter 2: Getting Started Lecture Notes 2-1 Solutions 2-17 Chapter 3: Growth of Functions Lecture Notes 3-1 Solutions 3-7 Chapter 4: Divide-and-Conquer Lecture Notes 4-1 Solutions 4-17 Chapter 5: Probabilistic Analysis and Randomized Algorithms Lecture Notes 5-1 Solutions 5-9 Chapter 6: Heapsort Lecture Notes 6-1 Solutions 6-10 Chapter 7: Quicksort Lecture Notes 7-1 Solutions 7-9 Chapter 8: Sorting in Linear Time Lecture Notes 8-1 Solutions 8-10 Chapter 9: Medians and Order Statistics Lecture Notes 9-1 Solutions 9-10 Chapter 11: Hash Tables Lecture Notes 11-1 Solutions 11-16 Chapter 12: Binary Search Trees Lecture Notes 12-1 Solutions 12-15 Chapter 13: Red-Black Trees Lecture Notes 13-1 Solutions 13-13 Chapter 14: Augmenting Data Structures Lecture Notes 14-1 Solutions 14-9 iv Contents Chapter 15: Dynamic Programming Lecture Notes 15-1 Solutions 15-21 Chapter 16: Greedy Algorithms Lecture Notes 16-1 Solutions 16-9 Chapter 17: Amortized Analysis Lecture Notes 17-1 Solutions 17-14 Chapter 21: Data Structures for Disjoint Sets Lecture Notes 21-1 Solutions 21-6 Chapter 22: Elementary Graph Algorithms Lecture Notes 22-1 Solutions 22-13 Chapter 23: Minimum Spanning Trees Lecture Notes 23-1 Solutions 23-8 Chapter 24: Single-Source Shortest Paths Lecture Notes 24-1 Solutions 24-13 Chapter 25: All-Pairs Shortest Paths Lecture Notes 25-1 Solutions 25-9 Chapter 26: Maximum Flow Lecture Notes 26-1 Solutions 26-12 Chapter 27: Multithreaded Algorithms Solutions 27-1 Index I-1

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值