麻省理工学院:《算法导论》(英文版) Lecture 2 Prof erik demaine

Introduction to algorithms 6.046J/18.401J/SMA5503 Lecture 2 Prof erik demaine
Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 2 Prof. Erik Demaine

Solving recurrences The analysis of merge sort from Lecture I required us to solve a recurrence ● Recurrences are like solving integrals erential equations, etc o Learn a few tricks Lecture 3: Applications of recurrences Day 3 Introduction to Algorithms
Day 3 Introduction to Algorithms L2.2 Solving recurrences • The analysis of merge sort from Lecture 1 required us to solve a recurrence. • Recurrences are like solving integrals, differential equations, etc. o Learn a few tricks. • Lecture 3: Applications of recurrences

Substitution method The most general method 1 Guess the form of the solution 2. Verify by induction 3. Solve for constants Example: T(n)=4T(n/2)+n ASsume that T(1=0(1). Guess O(n).(Prove O and Q2 separately. Assume that t(k)sck for k<n Prove T(n)s cn by induction Day 3 Introduction to Algorithms L2.3
Day 3 Introduction to Algorithms L2.3 Substitution method 1. Guess the form of the solution. 2. Verify by induction. 3. Solve for constants. The most general method: Example: T(n) = 4T(n/2) + n • [Assume that T(1) = Θ(1).] • Guess O(n3) . (Prove O and Ω separately.) • Assume that T(k) ≤ ck3 for k < n . • Prove T(n) ≤ cn3 by induction

Example of substitution T(n)=47(n/2)+n ≤4c(n/2)3+n =(c/2n3+n cn3-((c/2)n3-n+ desired-residual <Cn3← desire whenever(c/2)n3-n20, for example fc≥2andn≥1 residue Day 3 Introduction to Algorithms L24
Day 3 Introduction to Algorithms L2.4 Example of substitution 3 3 3 3 3 (( / 2) ) ( / 2) 4 ( / 2) ( ) 4 ( / 2) cn cn c n n c n n c n n T n T n n ≤ = − − = + ≤ + = + desired – residual whenever (c/2)n3 – n ≥ 0, for example, if c ≥ 2 and n ≥ 1. desired residual

Example(continued) We must also handle the initial conditions that is, ground the induction with base cases Base: I(n)=o(1) for all n<no, where no is a suitable constant For1≤n<mo, we have((1)≤cn3,ifwe pick c big enough This bound is not tight. Day 3 Introduction to Algorithms 2.5
Day 3 Introduction to Algorithms L2.5 Example (continued) • We must also handle the initial conditions, that is, ground the induction with base cases. • Base: T(n) = Θ(1) for all n < n0, where n0 is a suitable constant. • For 1 ≤ n < n0, we have “Θ(1)” ≤ cn3, if we pick c big enough. This bound is not tight!

a tighter upper bound? We shall prove that r(n)=o(n2) Assume that t(k)s ck for ko. lose Day 3 Introduction to Algorithms L2.6
Day 3 Introduction to Algorithms L2.6 A tighter upper bound? We shall prove that T(n) = O(n2). Assume that T(k) ≤ ck2 for k 0. Lose! [ desired – residual ]

A tighter upper bound! IDEA: Strengthen the inductive hypothesis Subtract a low-order term inductive hypothesis: T(k) 2 Pick c, b Day ig enough to handle the initial conditions Introduction to Algorithms 7
Day 3 Introduction to Algorithms L2.7 A tighter upper bound! IDEA: Strengthen the inductive hypothesis. • Subtract a low-order term. Inductive hypothesis: T(k) ≤ c1k2 – c2k for k 1. Pick c1 big enough to handle the initial conditions

Recursion -tree method A recursion tree models the costs(time)of a recursive execution of an algorithm The recursion tree method is good for generating guesses for the substitution method The recursion -tree method can be unreliable just like any method that uses ellipses(.) The recursion-tree method promotes intuition however Day 3 Introduction to Algorithms L2.8
Day 3 Introduction to Algorithms L2.8 Recursion-tree method • A recursion tree models the costs (time) of a recursive execution of an algorithm. • The recursion tree method is good for generating guesses for the substitution method. • The recursion-tree method can be unreliable, just like any method that uses ellipses (…). • The recursion-tree method promotes intuition, however

Example of recursion tree Solve(m)=70n/4)+7(m/2)+n Day 3 Introduction to Algorithms L2.9
Day 3 Introduction to Algorithms L2.9 Example of recursion tree Solve T(n) = T(n/4) + T(n/2) + n2:

Example of recursion tree Solve(m)=70n/4)+7(m/2)+ 7(n) duction to algorith L2.10
Day 3 Introduction to Algorithms L2.10 Example of recursion tree T(n) Solve T(n) = T(n/4) + T(n/2) + n2:
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 麻省理工学院:《算法导论》(英文版) Lecture Prof. Charles E. Leiserson.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)实验二 波形输入与仿真实现.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)综合、设计性实验指导书.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)封面.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)附录GW48EDA系统使用说明.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)实验一 可编程ASIC使用初步.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)实验五 A/D采样电路设计.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)实验四 只读存储器设计.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)实验三 序列信号发生器与序列信号检测器的设计.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)实验六 数字电压表设计.pdf
- 《数字平面艺术设计》课程教学资源(试卷习题)试题库.doc
- 华中科技大学:《MATLAB语言与控制系统仿真》课程教学资源(PPT课件讲稿)第四章 控制系统的分析方法.ppt
- 华中科技大学:《MATLAB语言与控制系统仿真》课程教学资源(PPT课件讲稿)第五章 SIMULINK仿真基础.ppt
- 华中科技大学:《MATLAB语言与控制系统仿真》课程教学资源(PPT课件讲稿)第二章 matlab语言基础.ppt
- 华中科技大学:《MATLAB语言与控制系统仿真》课程教学资源(PPT课件讲稿)第三章 控制系统的数学描述与建模.ppt
- 华中科技大学:《MATLAB语言与控制系统仿真》课程教学资源(PPT课件讲稿)第一章 计算机辅助设计与仿真技术概述.ppt
- 沈阳师范大学:《数据库应用基础》应试指导.ppt
- 沈阳师范大学:《数据库应用基础》课堂测试.ppt
- 沈阳师范大学:《数据库应用基础》第12章 数据库应用.ppt
- 沈阳师范大学:《数据库应用基础》编程练习(1).ppt
- 麻省理工学院:《算法导论》(英文版) Lecture 3 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版)Lecture 4 Prof. charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版)Lecture 5 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 6 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 7 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 8 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 9 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 10 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 11 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 12 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版)Lecture 13 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 14 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 15 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 16 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版)Lecture 17 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 18 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 19 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 20 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 21 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 22 Prof charles e. leiserson.pdf