“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
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
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
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
Selection Problem using MM (with r = 5) [ pp. 38-46, 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