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

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

1 CMPS 101 Algorithms and Abstract Data Types Recurrence Relations Iteration Method Recall the following example from the induction handout.   + = = 2 1 ) 2 / ( 1 0 ) ( 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   0 ) 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 0 ) 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 0 ) ( n n S n n S has solution   ) lg( ) ( n n S = , and hence also )) (log( ) ( n n S Θ = .

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

View Full Document
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 of a recurrence without changing the asymptotic solution. The following recurrence satisfies )) (log( ) ( n n T Θ = for any values of the constants c, d , and 0 n .   ( ) + < = 0 0 2 / 1 ) ( n n d n T n n c n T Using the iteration method yields:   ( ) 2 / ) ( n T d n T + =   ( ) 2 2 / n T d d + + = M   ( ) k n T kd 2 / + = We seek the first (i.e. the smallest) integer k such that   0 2 / n n k < . This is equivalent to 0 2 / n n k < , whence k n n 2 0 < k n k k < - ) 2 / lg( 1 (since k is the least integer satisfying the previous inequality)   0 / lg( 1 n n k = -   1 ) / lg( 0 + = n n k Thus   ( ) c d n n n T + + = 1 ) / lg( ) ( 0 for 0 n n , and hence )) (log( ) ( n n T Θ = as claimed. It is often difficult or impossible to determine an exact solution via the iteration method, while it is possible to obtain an asymptotic solution. Consider   + = = 2 ) 2 / ( 1 1 ) ( 2 n n n T n n T Upon iterating this recurrence we find 1 2 ) ( 1 0 2 + = - = k
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/10/2010 for the course CMPS 101 taught by Professor Tantalo,p during the Fall '08 term at University of California, Santa Cruz.

### Page1 / 6

Recurrence - 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