Data Structures and Algorithms CMPSC 465

Similar documents
Algorithm Design and Analysis

Data Structures and Algorithms CMPSC 465

Section IV.6: The Master Method and Applications

4 7x =250; 5 3x =500; Read section 3.3, 3.4 Announcements: Bell Ringer: Use your calculator to solve

CS473-Algorithms I. Lecture 3. Solving Recurrences. Cevdet Aykanat - Bilkent University Computer Engineering Department

Design and Analysis of Algorithms Recurrence. Prof. Chuhua Xian School of Computer Science and Engineering

Read section 3.3, 3.4 Announcements:

What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency Asympt

Math 31S. Rumbos Fall Solutions to Assignment #16

5. Solving recurrences

7 - Continuous random variables

Similar idea to multiplication in N, C. Divide and conquer approach provides unexpected improvements. Naïve matrix multiplication

Improper Integrals. Type I Improper Integrals How do we evaluate an integral such as

5.2 Exponent Properties Involving Quotients

Data Structures and Algorithms CSE 465

CS 4407 Algorithms Lecture 3: Iterative and Divide and Conquer Algorithms

NUMERICAL INTEGRATION

Solution Manual. for. Fracture Mechanics. C.T. Sun and Z.-H. Jin

The graphs of Rational Functions

f(x) dx, If one of these two conditions is not met, we call the integral improper. Our usual definition for the value for the definite integral

Algorithm Design and Analysis

AP Calculus Multiple Choice: BC Edition Solutions

Numerical Analysis: Trapezoidal and Simpson s Rule

Math 113 Exam 2 Practice

A recursive construction of efficiently decodable list-disjunct matrices

Lab 11 Approximate Integration

( dg. ) 2 dt. + dt. dt j + dh. + dt. r(t) dt. Comparing this equation with the one listed above for the length of see that

Module 9: Tries and String Matching

Module 9: Tries and String Matching

Lecture 20: Numerical Integration III

Lecture 17. Integration: Gauss Quadrature. David Semeraro. University of Illinois at Urbana-Champaign. March 20, 2014

20 MATHEMATICS POLYNOMIALS

Math& 152 Section Integration by Parts

W. We shall do so one by one, starting with I 1, and we shall do it greedily, trying

Math 1B, lecture 4: Error bounds for numerical methods

Matrices, Moments and Quadrature, cont d

p-adic Egyptian Fractions

CS683: calculating the effective resistances

Best Approximation. Chapter The General Case

The Regulated and Riemann Integrals

Lecture 3 ( ) (translated and slightly adapted from lecture notes by Martin Klazar)

CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms

When a force f(t) is applied to a mass in a system, we recall that Newton s law says that. f(t) = ma = m d dt v,

. Double-angle formulas. Your answer should involve trig functions of θ, and not of 2θ. sin 2 (θ) =

Dynamics: Newton s Laws of Motion

Recitation 3: More Applications of the Derivative

Improper Integrals. Introduction. Type 1: Improper Integrals on Infinite Intervals. When we defined the definite integral.

Math 8 Winter 2015 Applications of Integration

4.1. Probability Density Functions

Integrals - Motivation

Math 113 Exam 2 Practice

38 Riemann sums and existence of the definite integral.

13.4. Integration by Parts. Introduction. Prerequisites. Learning Outcomes

1.2. Linear Variable Coefficient Equations. y + b "! = a y + b " Remark: The case b = 0 and a non-constant can be solved with the same idea as above.

1 Probability Density Functions

Lecture 14: Quadrature

Handout: Natural deduction for first order logic

Anti-derivatives/Indefinite Integrals of Basic Functions

CS 275 Automata and Formal Language Theory

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!)

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

Chapter 2. Recurrence Relations. Divide and Conquer. Divide and Conquer Strategy. Another Example: Merge Sort. Merge Sort Example. Merge Sort Example

If deg(num) deg(denom), then we should use long-division of polynomials to rewrite: p(x) = s(x) + r(x) q(x), q(x)

The Fundamental Theorem of Calculus. The Total Change Theorem and the Area Under a Curve.

Lecture 6: Singular Integrals, Open Quadrature rules, and Gauss Quadrature

Data Structures and Algorithms CSE 465

Main topics for the First Midterm

A REVIEW OF CALCULUS CONCEPTS FOR JDEP 384H. Thomas Shores Department of Mathematics University of Nebraska Spring 2007

Exam 1 Solutions (1) C, D, A, B (2) C, A, D, B (3) C, B, D, A (4) A, C, D, B (5) D, C, A, B

APPROXIMATE INTEGRATION

1 The Riemann Integral

P 3 (x) = f(0) + f (0)x + f (0) 2. x 2 + f (0) . In the problem set, you are asked to show, in general, the n th order term is a n = f (n) (0)

Euler, Ioachimescu and the trapezium rule. G.J.O. Jameson (Math. Gazette 96 (2012), )

DIRECT CURRENT CIRCUITS

Ordinary Differential Equations- Boundary Value Problem

The area under the graph of f and above the x-axis between a and b is denoted by. f(x) dx. π O

Design Patterns for Data Structures. Chapter 3. Recursive Algorithms

Connected-components. Summary of lecture 9. Algorithms and Data Structures Disjoint sets. Example: connected components in graphs

Resistors. Consider a uniform cylinder of material with mediocre to poor to pathetic conductivity ( )

Best Approximation in the 2-norm

5.5 The Substitution Rule

Physics 202, Lecture 10. Basic Circuit Components

du = C dy = 1 dy = dy W is invertible with inverse U, so that y = W(t) is exactly the same thing as t = U(y),

Math 120 Answers for Homework 13

Harvard University Computer Science 121 Midterm October 23, 2012

8 Laplace s Method and Local Limit Theorems

A. Limits - L Hopital s Rule ( ) How to find it: Try and find limits by traditional methods (plugging in). If you get 0 0 or!!, apply C.! 1 6 C.

6.2 CONCEPTS FOR ADVANCED MATHEMATICS, C2 (4752) AS

Math 520 Final Exam Topic Outline Sections 1 3 (Xiao/Dumas/Liaw) Spring 2008

CS 275 Automata and Formal Language Theory

Week 10: Riemann integral and its properties

E 1 (n) = E 0 (n-1) E 0 (n) = E 0 (n-1)+e 0 (n-2) T(n -1)=2E 0 (n-2) + E 0 (n-3)

We partition C into n small arcs by forming a partition of [a, b] by picking s i as follows: a = s 0 < s 1 < < s n = b.

CMSC 330: Organization of Programming Languages

Analysis of Algorithms - Using Asymptotic Bounds -

MASTER CLASS PROGRAM UNIT 4 SPECIALIST MATHEMATICS WEEK 11 WRITTEN EXAMINATION 2 SOLUTIONS SECTION 1 MULTIPLE CHOICE QUESTIONS

5.1 How do we Measure Distance Traveled given Velocity? Student Notes

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

Chapter 9: Inferences based on Two samples: Confidence intervals and tests of hypotheses

Transcription:

Dt Structures nd Algorithms CMPSC 465 LECTURE 10 Solving recurrences Mster theorem Adm Smith S. Rskhodnikov nd A. Smith; bsed on slides by E. Demine nd C. Leiserson

Review questions Guess the solution to the recurrence: T(n)=2T(n/3)+n 3/2. (Answer: Θ(n 3/2 ).) Drw the recursion tree for this recurrence.. Wht is its height? b. Wht is the number of leves in the tree? (Answer: h=log 3 n.) (Answer: n (1/log 3).)

The mster method The mster method pplies to recurrences of the form T(n) = T(n/b) +, where 1, b > 1, nd f is symptoticlly positive, tht is >0 for ll n > n 0.

Three common cses Compre with n log b : 1. = O(n log b ε ) for some constnt ε > 0. grows polynomilly slower thn n log b (by n n ε fctor). Solution: T(n) = Θ(n log b ).

Three common cses Compre with n log b : 1. = O(n log b ε ) for some constnt ε > 0. grows polynomilly slower thn n log b (by n n ε fctor). Solution: T(n) = Θ(n log b ). 2. = Θ(n log b lg k n) for some constnt k 0. nd n log b grow t similr rtes. Solution: T(n) = Θ(n log b lg k+1 n).

Three common cses (cont.) Compre with n log b : 3. = Ω(n log b + ε ) for some constnt ε > 0. grows polynomilly fster thn n log b (by n n ε fctor), nd stisfies the regulrity condition tht f (n/b) c for some constnt c < 1. Solution: T(n) = Θ( ).

Ide of mster theorem Recursion tree: f (n/b) f (n/b) f (n/b 2 ) f (n/b 2 ) f (n/b 2 ) f (n/b)

Ide of mster theorem Recursion tree: f (n/b) f (n/b) f (n/b 2 ) f (n/b 2 ) f (n/b 2 ) f (n/b) f (n/b) 2 f (n/b 2 )

Ide of mster theorem h = log b n Recursion tree: f (n/b) f (n/b) f (n/b 2 ) f (n/b 2 ) f (n/b 2 ) f (n/b) f (n/b) 2 f (n/b 2 )

Ide of mster theorem h = log b n Recursion tree: f (n/b) f (n/b) f (n/b 2 ) f (n/b 2 ) f (n/b 2 ) f (n/b) f (n/b) 2 f (n/b 2 ) #leves = h = log bn = n log b n log b

Ide of mster theorem h = log b n Recursion tree: f (n/b) f (n/b) f (n/b 2 ) f (n/b 2 ) f (n/b 2 ) f (n/b) f (n/b) 2 f (n/b 2 ) CASE 1: The weight increses geometriclly from the root to the leves. The leves hold constnt frction of the totl weight. n log b Θ(n log b )

Ide of mster theorem h = log b n Recursion tree: f (n/b) f (n/b) f (n/b 2 ) f (n/b 2 ) f (n/b 2 ) f (n/b) f (n/b) 2 f (n/b 2 ) CASE 2: (k = 0) The weight is pproximtely the sme on ech of the log b n levels. n log b Θ(n log b lg n)

Ide of mster theorem h = log b n Recursion tree: f (n/b) f (n/b) f (n/b 2 ) f (n/b 2 ) f (n/b 2 ) f (n/b) f (n/b) 2 f (n/b 2 ) CASE 3: The weight decreses geometriclly from the root to the leves. The root holds constnt frction of the totl weight. n log b Θ( )

Exmples EX. T(n) = 4T(n/2) + n = 4, b = 2 n log b = n 2 ; = n. CASE 1: = O(n 2 ε ) for ε = 1. T(n) = Θ(n 2 ).

Exmples EX. T(n) = 4T(n/2) + n = 4, b = 2 n log b = n 2 ; = n. CASE 1: = O(n 2 ε ) for ε = 1. T(n) = Θ(n 2 ). EX. T(n) = 4T(n/2) + n 2 = 4, b = 2 n log b = n 2 ; = n 2. CASE 2: = Θ(n 2 lg 0 n), tht is, k = 0. T(n) = Θ(n 2 lg n).

Exmples EX. T(n) = 4T(n/2) + n 3 = 4, b = 2 n log b = n 2 ; = n 3. CASE 3: = Ω(n 2 + ε ) for ε = 1 nd 4(n/2) 3 cn 3 (reg. cond.) for c = 1/2. T(n) = Θ(n 3 ).

Exmples EX. T(n) = 4T(n/2) + n 3 = 4, b = 2 n log b = n 2 ; = n 3. CASE 3: = Ω(n 2 + ε ) for ε = 1 nd 4(n/2) 3 cn 3 (reg. cond.) for c = 1/2. T(n) = Θ(n 3 ). EX. T(n) = 4T(n/2) + n 2 /lg n = 4, b = 2 n log b = n 2 ; = n 2 /lg n. Mster method does not pply. In prticulr, for every constnt ε > 0, we hve n ε = ω(lg n).