Find Median Of Array In Linear Time. Whileelementssize-counter filterSize forint i 0. Return findMedian groupsMedians.
You can verify in linear time how many elements are above that experimented pivot and how many are below. Find-kthA k B medianA1 A5 medianA6 A10 pivot find-kthB B2. Those counts give you the direction of your bin.
Now a1a2a3a n5 represent the medians of each group.
N 5 arr 4 1 2 6 5 Output. If the array length is 2 find the weighted median by exhaustive search. GroupsMedians i findMedian splittedData i. Those counts give you the direction of your bin.
