This preview shows pages 1–5. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 1 Dealing with floors and ceilings in divideandconquer recurrences COMP170 Discrete Mathematical Tools for Computer Science 2 Note that, when n is not a power of 2 , a D&C recurrence will split n into b n/ 2 c and d n/ 2 e . Eq (*) then becomes We have seen that when n is a power of 2 . T ( n ) = 2 T ( n/ 2) + n if n ≥ 2 , 1 if n = 1 . is n (log 2 n + 1) . What happens when n is not a power of 2 ? (*) T ( n ) = T ( b n/ 2 c ) + T ( d n/ 2 e ) + n if n ≥ 2 , 1 if n = 1 . When n is a power of 2 then (**) is defined by (*) . (**) 3 Assume the following Theorem (to be proven later): Theorem 1 If n 1 ≤ n 2 , then T ( n 1 ) ≤ T ( n 2 ) Let m = 2 i +1 be the smallest power of 2 ≥ n . Since the interval [ n, 2 n 1] contains a power of 2 we have m < 2 n . So, T ( n ) ≤ T ( m ) = m (1 + log 2 m ) ≤ 2 n (1 + log 2 2 n ) = 2 n (2 + log 2 n ) This gives us an upper bound . 4 On the other hand, m/ 2 = 2 i ≤ n < m . So, T ( n ) ≥ T ( m 2 ) = m 2 (1 + log 2 m 2 ) > n 2 (1 + log 2 n 2 ) = n 2 log 2 n This gives us a lower bound . 5...
View Full
Document
 Spring '10
 M.J.Golin
 Computer Science

Click to edit the document details