Author |
Topic: Median of 5 (Read 37020 times) |
|
Jon Anderson
Guest
|
Just so you know,the median of median method is used to find the pivot for solving the selection problem, not for doing a quicksort. The selection problem is that of finding the kth smallest element in an unsorted list of n elements. The best approach is to apply the quicksort algorithm. If the pivot lands in spot k, then you are done. Otherwise, you have to run the algorithm on whichever half of the list k happens to be in, not both as in the quicksort. It can be shown that by using the median-of-medians approach, the worst case scenario is still solved in linear time. (22n by comparisions)
|
|
IP Logged |
|
|
|
|