chap9-solutions - Selected Solutions for Chapter 9: Medians...

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

View Full Document Right Arrow Icon
Selected Solutions for Chapter 9: Medians and Order Statistics Solution to Exercise 9.3-1 For groups of 7, the algorithm still works in linear time. The number of elements greater than x (and similarly, the number less than x ) is at least 4 ±² 1 2 l n 7 m ³ N 2 ´ ± 2n 7 N 8 ; and the recurrence becomes T.n/ ² T. d n=7 e / C T.5n=7 C 8/ C O.n/ ; which can be shown to be O.n/ by substitution, as for the groups of 5 case in the text. For groups of 3, however, the algorithm no longer works in linear time. The number of elements greater than x , and the number of elements less than x , is at least 2 ±² 1 2 l n 3 m ³ N 2 ´ ± n 3 N 4 ; and the recurrence becomes T.n/ ² T. d n=3 e / C T.2n=3 C 4/ C O.n/ ; which does not have a linear solution. We can prove that the worst-case time for groups of 3 is .n lg n/ . We do so by deriving a recurrence for a particular case that takes .n lg n/ time. In counting up the number of elements greater than x (and similarly, the num- ber less than x ), consider the particular case in which there are exactly l 1 2 l n 3 mm groups with medians ± x and in which the “leftover” group does contribute 2 elements greater than x . Then the number of elements greater than x is exactly 2 µl 1 2 l n 3 mm N 1 C 1 (the N 1 discounts x ’s group, as usual, and the C 1 is con- tributed by x ’s group) D 2 d n=6 e N 1 , and the recursive step for elements ² x has n N .2 d n=6 e N
Background image of page 1

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

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

This note was uploaded on 04/20/2010 for the course IE ie200 taught by Professor . during the Spring '10 term at 카이스트, 한국과학기술원.

Page1 / 3

chap9-solutions - Selected Solutions for Chapter 9: Medians...

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

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