L13_Adv_DandC_print

L13_Adv_DandC_print - 1 Dealing with floors and ceilings in

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Dealing with floors and ceilings in divide-and-conquer 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

Page1 / 9

L13_Adv_DandC_print - 1 Dealing with floors and ceilings in

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online