java,algorithm,median-of-medians

There are quite a few mistakes: The method pivot should not modify the array a. It should just find a pivot for the future partition. A dirty fix is to call pivot(a.clone(), left, right);. (You shouldn't do this, just to give you an idea.) Math.ceil((right - left) / 5) is...

sorting,recursion,recurrence-relation,quickselect,median-of-medians

Best attempt: That equation is only for when you do the median of groups of 5. Otherwise it will change. The an part of the equation is the time it takes for the algorithm to go through all the elements and group them into 5. The T(n/5) is the time...

javascript,algorithm,median-of-medians

The selection algorithm needs to rearrange the input vector, since it does a series of partitions. So it's reasonable to assume that it is possible to rearrange the input vector in order to find the median. One simple possible strategy is to interleave the groups of five, instead of making...

time-complexity,quicksort,quickselect,median-of-medians

According to Wiki, The approximate median-selection algorithm can also be used as a pivot strategy in quicksort, yielding an optimal algorithm, with worst-case complexity O(n log n). This is because the median of medians algorithm prevents the bad partitioning that would occur in naive quicksort on an already sorted array....