In the normal partitioning process of quicksort, if partition position s=m, stop; if s < m, use the same techinque to find (m-s)th position; If s > m, find the mth smallest element in the left hand.
Finding the mth smallest of a given set on n elements.
[Problem posed by C.A.R.Hoare] Suppose that, instead of sorting an entire file, we only want to determine the mth smallest of a given set of n elements. Show that quicksort can be adapted to this purpose avoiding many of the computations required to do a complete sort. ( Knuth(1998)The Art of Computer Programming Vol.3:Sorting and Searching, p.136 // Bentley (2011) Programming Pearls Column 11 )
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment