Presentation is loading. Please wait.

Presentation is loading. Please wait.

“MM – Median of Medians”

Similar presentations


Presentation on theme: "“MM – Median of Medians”"— Presentation transcript:

1 “MM – Median of Medians”
Game: There are n students in the class. Students are partitioned into n/r groups of size r (r is odd = 3, 5, or 7). Each team find its median using just any algorithm. Now we have n/r medians. Find MM (Median of Medians) using just any algorithms. . CS331 D. & A. of Algorithms

2 To show why MM ≥ ¼ of n & MM ≤ ¼ of n :
Example: 35 (n) elements are partitioned into 7 (n/r) groups of size 5 (r) Elements  MM Non- decreasing Order (all columns) MM (Median of Medians) The middle row is in non-decreasing order Elements  MM . CS331 D. & A. of Algorithms

3 To show why MM ≥ ¼ of n & MM ≤ ¼ of n :
Example: 21 (n) elements are partitioned into into 7 (n/r) groups of size 3 (r) Elements  MM Non- decreasing Order (all columns) MM (Median of Medians) The middle row is in non-decreasing order Elements  MM . CS331 D. & A. of Algorithms

4 To show why MM ≥ ¼ of n & MM ≤ ¼ of n :
Example: 25 (n) elements are partitioned into into 5 (n/r) groups of size 5 (r) Elements  MM Non- decreasing Order (all columns) MM (Median of Medians) The middle row is in non-decreasing order Elements  MM . CS331 D. & A. of Algorithms

5 Selection Problem using MM (with r = 5)
[ pp , Divide&Conquer class notes ] Given a list of n elements, find the kth tallest one. Finding n/r medians takes linear time. Finding MM from n/5 medians is same as the orginal problem of finding the kth largest element. MM is at least ≥ and ≤ ¼ of n. Therefore the size of the remaining subproblem is no more than ¾ of n . CS331 D. & A. of Algorithms


Download ppt "“MM – Median of Medians”"

Similar presentations


Ads by Google