Recurrence Relations Recurrence Relations A recurrence relation is


































- Slides: 34

Recurrence Relations

Recurrence Relations • A recurrence relation is an equation which is defined in terms of itself. • Many algorithms, particularly divide and conquer algorithms, have time complexities which are naturally modeled by recurrence relations

Example Merge Sort • Merge-Sort(A, p, r): if p < r then q¬(p+r)/2 Merge-Sort(A, p, q) Merge-Sort(A, q+1, r) Merge(A, p, q, r) •

Solving Recurrences • We will show 3 ways of solving recurrences: – Substitution method - Guess and prove • – Iteration method • – Use mathematical induction to solve your recursion Break the sums into a mathematical series Master theorem • Check for an instant solution

Substitution method • Guess a solution and them prove it using mathematical induction. • To guess the solution, play around with small values for insight n 0 1 2 3 4 5 6 7 0 1 3 7 15 31 63 127

Prove by induction • Claim 1. Show that the basis is true: 2. Now assume true for T(n-1 ) 3. Using this assumption show:

Iteration method • Example • How many terms until we reach T(1) ?

Iteration method

Recursion Trees •

Recursion Trees •

Recursion Trees

Recursion Trees •

Master Theorem • A powerful theorem allowing to solve a large class of recursion relations of the form where • There are 3 cases to remember: 1. If for some constant then

Master Theorem 2. If then 3. If for some constant and for some c < 1 then for all sufficiently large n

Using Master Theorem • T(n) = 4 T(n/2) + n • Case 1 of master theorem

Using Master Theorem •

Using Master Theorem • • Use case 2 of Master theorem

Using Iteration •

Using Master theorem •

Examples • • Use Master theorem case 1 where є = 1/6

Master theorem

Examples • Use case 2 of Master Theorem

Examples • Use Master Theorem – case 3

Example • Fits case 3 of Master theorem ?

Examples

Examples • Master Theorem – does not fit • Substitution method – too complicated • Recursion tree

• T(n) is at least the price for a complete tree of height T(n) is at most the price for a complete tree of height

• • • i=0 i=1 i=2 i=3 i=k n (3/4)n (9/16)n (27/64)n (3/4)^k * n





Regularity of Case 3 •

Example •
Algorithm recurrence relation
Recurrence relation for merge sort
Recurrence relation of recursive selection sort
Recurrence computer science
Recurrence relation solver
Recurrence relation for linear search
Recurrence relation in discrete mathematics
Recurrence relation
Recurrence relation exercises
Linear homogeneous recurrence relation examples
Discrete probability and advanced counting techniques
Asymptotic cheat sheet
The expression is a
Why is merge sort n log n
Rabbits and recurrence relations
Employee relations in public relations
Hsv-2 oral transmission rates
What is recurrence equation
Cla3g
Recurrence discrete math
Recurrence rate
Recurrence data structures
Hooke's law set up
7-2 inverses of relations and functions
Sectional views
Function vs relation
Pleasure curve
Protrusive jaw relation
Pertanyaan tentang media relations
Symmetric relation example
A rhythmic disturbance that transfers energy
Pengertian public relation
Pengertian customer relationship
Concept of
Class 5 maths factors and multiples