{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Recurrence - 1 CMPS 101 Algorithms and Abstract Data Types...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 CMPS 101 Algorithms and Abstract Data Types Recurrence Relations Iteration Method Recall the following example from the induction handout. ≥ + = = 2 1 ) 2 / ( 1 ) ( n n T n n T We begin by illustrating a solution technique called Iteration , which consists of repeatedly substituting the recurrence into itself until a pattern emerges. ) 2 / ( 1 ) ( n T n T + = ) 2 / ( 2 ) 2 / 2 / ( 1 1 2 n T n T + = + + = ) 2 / ( 3 ) 2 / 2 / ( 1 2 3 2 n T n T + = + + = M ) 2 / ( k n T k + = This process must terminate when the recursion depth k is at its maximum, i.e. when 1 2 / = k n . To solve this equation for k in terms of n , we use the inequality definition of the floor function. 2 2 / 1 < ≤ k n ∴ 1 2 2 + < ≤ k k n ∴ 1 ) lg( + < ≤ k n k ∴ ) lg( n k = Thus for the recursion depth ) lg( n k = we have ) 1 ( ) 2 / ( = = T n T k , and hence the solution to the above recurrence is ) lg( ) ( n n T = . It follows that )) (log( ) ( n n T Θ = . Exercise Check directly that ) lg( ) ( n n T = is the solution to the above recurrence relation, i.e. check that ) 1 ( = T , and for any 2 ≥ n , that ) 2 / ( 1 ) ( n T n T + = . Exercise Use this same technique to show that the recurrence ≥ + = = 2 1 ) 2 / ( 1 ) ( n n S n n S has solution ) lg( ) ( n n S = , and hence also )) (log( ) ( n n S Θ = . 2 Comparing the solutions to the preceding examples, we see that replacing floor by ceiling has no affect on the asymptotic solution )) (log( n Θ , while the exact solutions are different: ) lg( n vs. ) lg( n . We can change other details in a recurrence without changing the asymptotic solution. The following recurrence satisfies )) (log( ) ( n n T Θ = for any values of the constants c, d , and n ....
View Full Document

{[ snackBarMessage ]}

### Page1 / 4

Recurrence - 1 CMPS 101 Algorithms and Abstract Data Types...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online