Asymptotics and Recurrence Equations Prepared by John Reif, Ph.D. Analysis of Algorithms.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

 The running time of an algorithm as input size approaches infinity is called the asymptotic running time  We study different notations for asymptotic.
CSE 373: Data Structures and Algorithms Lecture 5: Math Review/Asymptotic Analysis III 1.
Appendix B Solving Recurrence Equations : With Applications to Analysis of Recursive Algorithms.
Deterministic Selection and Sorting Prepared by John Reif, Ph.D. Analysis of Algorithms.
April 9, 2015Applied Discrete Mathematics Week 9: Relations 1 Solving Recurrence Relations Another Example: Give an explicit formula for the Fibonacci.
Algorithms Recurrences. Definition – a recurrence is an equation or inequality that describes a function in terms of its value on smaller inputs Example.
Chapter 1 – Basic Concepts
CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis Tyler Robison Summer
Recurrence Relations Reading Material –Chapter 2 as a whole, but in particular Section 2.8 –Chapter 4 from Cormen’s Book.
Asymptotic Growth Rate
Cutler/HeadGrowth of Functions 1 Asymptotic Growth Rate.
Discrete Structures Chapter 6 Recurrence Relations
Analyzing algorithms & Asymptotic Notation BIO/CS 471 – Algorithms for Bioinformatics.
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 3 Recurrence equations Formulating recurrence equations Solving recurrence equations.
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE 3 Recurrence equations Formulating recurrence equations Solving recurrence equations.
Analysis of Recursive Algorithms
25 June 2015Comp 122, Spring 2004 Asymptotic Notation, Review of Functions & Summations.
Tirgul 2 Asymptotic Analysis. Motivation: Suppose you want to evaluate two programs according to their run-time for inputs of size n. The first has run-time.
Recurrence Relations Reading Material –Chapter 2 as a whole, but in particular Section 2.8 –Chapter 4 from Cormen’s Book.
Recurrences Part 3. Recursive Algorithms Recurrences are useful for analyzing recursive algorithms Recurrence – an equation or inequality that describes.
David Luebke 1 8/17/2015 CS 332: Algorithms Asymptotic Performance.
Analysis of Recursive Algorithms October 29, 2014
Instructor Neelima Gupta
Applied Discrete Mathematics Week 9: Relations
7.2 Solving Recurrence Relations. Definition 1 (p. 460)- LHRR-K Def: A linear homogeneous recurrence relations of degree k with constant coefficients.
Time Complexity Dr. Jicheng Fu Department of Computer Science University of Central Oklahoma.
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
Mathematics Review and Asymptotic Notation
Design and Analysis of Algorithms - Chapter 21 Analysis of Algorithms b Issues: CorrectnessCorrectness Time efficiencyTime efficiency Space efficiencySpace.
Analysis of Algorithms
1 Computer Algorithms Lecture 7 Master Theorem Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR.
2IL50 Data Structures Fall 2015 Lecture 2: Analysis of Algorithms.
Chapter 8 With Question/Answer Animations 1. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Analyzing algorithms & Asymptotic Notation BIO/CS 471 – Algorithms for Bioinformatics.
Chapter 2 Mathematical preliminaries 2.1 Set, Relation and Functions 2.2 Proof Methods 2.3 Logarithms 2.4 Floor and Ceiling Functions 2.5 Factorial and.
CSC 413/513: Intro to Algorithms Merge Sort Solving Recurrences.
Asymptotic Analysis-Ch. 3
Algorithms Merge Sort Solving Recurrences The Master Theorem.
Program Efficiency & Complexity Analysis. Algorithm Review An algorithm is a definite procedure for solving a problem in finite number of steps Algorithm.
Algorithm Analysis CS 400/600 – Data Structures. Algorithm Analysis2 Abstract Data Types Abstract Data Type (ADT): a definition for a data type solely.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Growth of Functions. 2 Analysis of Bubble Sort 3 Time Analysis – Best Case The array is already sorted – no swap operations are required.
CSC310 © Tom Briggs Shippensburg University Fundamentals of the Analysis of Algorithm Efficiency Chapter 2.
CMSC 341 Asymptotic Analysis. 2 Complexity How many resources will it take to solve a problem of a given size? –time –space Expressed as a function of.
Time Complexity of Algorithms (Asymptotic Notations)
Second-Order Differential
7.2 Solving Linear Recurrence Relations Some of these recurrence relations can be solved using iteration or some other ad hoc technique. However, one important.
David Luebke 1 1/6/2016 CS 332: Algorithms Asymptotic Performance.
Asymptotic Performance. Review: Asymptotic Performance Asymptotic performance: How does algorithm behave as the problem size gets very large? Running.
ADVANCED ALGORITHMS REVIEW OF ANALYSIS TECHNIQUES (UNIT-1)
Spring 2015 Lecture 2: Analysis of Algorithms
Advanced Algorithms Analysis and Design
Mathematical Analysis of Recursive Algorithm CSG3F3 Lecture 7.
Advanced Algorithms Analysis and Design By Dr. Nazir Ahmad Zafar Dr Nazir A. Zafar Advanced Algorithms Analysis and Design.
Mathematical Foundations (Growth Functions) Neelima Gupta Department of Computer Science University of Delhi people.du.ac.in/~ngupta.
CSG523/ Desain dan Analisis Algoritma
CSG523/ Desain dan Analisis Algoritma
Analysis of Algorithms
Modeling with Recurrence Relations
Chapter 5 Series Solutions of Linear Differential Equations.
Analysis of Algorithms
Solving Recurrence Relations
Ch 3: Growth of Functions Ming-Te Chi
Advanced Algorithms Analysis and Design
At the end of this session, learner will be able to:
Discrete Mathematics 7th edition, 2009
Introduction To Algorithms
Algorithms Recurrences.
Presentation transcript:

Asymptotics and Recurrence Equations Prepared by John Reif, Ph.D. Analysis of Algorithms

Asymptotics and Recurrence Equations a)Computational Complexity of a Program b)Worst Case and Expected Bounds c)Definition of Asymptotic Equations d)Solution of Recurrence Notation

Readings Main Reading Selection: CLR, Chapter 3, 4 and Appendix A

Goal To estimate and compare growth rates of functions Ignore constant factors of growth

“f(n) is asymptotically equal to g(n)”

”f(n) is little o g(n) ” f(n) is o(g(n)) if

”f(n) is big O g(n) ” f(n) is O(g(n)) if

Example of f(n) is O(g(n))

“f(n) is order at least g(n)” f(n) is (g(n)) if

Example of f(n) is  (g(n))

“f(n) is order tight with g(n)” f(n) is (g(n)) if

Suppose my algorithm runs in time O(n) Don’t say: “his runs in time O(n 2 ) so is worse” But prove: “his runs in time (n 2 ) so is worse” Must find a worst case input of length n for which his algorithm takes time > cn 2 for all n > n 0

Use of O Notation N is O (n 2 ) sometimes written n = O (n 2 ) But n 2 is not O(n) so can’t use identities!  The two sides of the equality do not play a symmetric role

Use of Asymptotic Notation Write As Example

Convergent Power Sum A polynomial is asymptotically equal to its leading term as x  

Sums of Powers for n   Or equivalently

Examples 2 nd order asymptotic expansion

Asymptotic Expansion of f(n) as n  n 0 If and

Bounding Sums by Integrals

Bounding Sums by Integrals (cont’d) So Example then

Bounding Sums by Integrals (cont’d) So Since So

Other Approximations Derived from Integrals Harmonic Numbers

Stirling’s Approximation for Factorial Factorial n! = 1· 2 · 3 · · · (n-1) · n So

Recurrence Equations (over integers) Homogenous of degree d n > d Given constant coefficients a 1, …, a d initial valuesx 1, x 2, …, x d

Example: Fibonacci Sequence n > 2 F n = F n-1 + F n-2 F 0 = 0, F 1 =1

Solution of Fibonacci Sequence “golden ratio” where

Solution of Fibonacci Sequence (cont’d) Hence

A Useful Theorem c > 0, d > 0 If then

Proof Is solution

Cases

Example: Mergesort input list L of length N if N=1 then return L else do let L 1 be the first elements of L let L 2 be the last elements of L M 1  Mergesort (L 1 ) M 2  Mergesort (L 2 ) return Merge (M 1, M 2 )

Time Bounds of Mergesort Initial Value T(1) = c 1 for N > 1 for some constants c 1, c 2 > 1

Time Bound (cont’d) N > 1 guess Holds if Solution

Time Bound (cont’d) N > 1 Transform Variables Recurrence equation:

Solve by usual methods for recurrence equations

Advanced Material Exact Solution of Recurrence Relations

Homogenous Recurrence Relations (no constant additive term) Solve: try Multiply by Get characteristic equation:

Case of Distinct Roots Distinct Roots r 1, r 2, …, r d Where r i is dominant root

Other Case Roots are not distinct r 1 = r 2 = r 3 Then solutions not independent, so additional terms:

Inhomogenous Recurrence Equations Nonzero constant term Solution Method (1) Solve homogenous equation

Solution Method 1)Solve homogenous equation 2)Case, add particular solution

Solution Method (cont’d) Case, add particular solution 3)Add particular and homogeneous solutions, and solve for constants This is all we usually need!!

Asymptotics and Recurrence Equations Prepared by John Reif, Ph.D. Analysis of Algorithms