The Generalization of Quicksort Shyue-Horng Shiau Chang-Biau Yang Department of Computer Science and Engineering National Sun Yat-Sen University Kaohsiung, Taiwan 804, Republic of China shiaush@cse.nsysu.edu.tw cbyang@cse.nsysu.edu.tw Abstract In this paper, we propose a generalization of quicksort to solve the problem of sorting the first largest elements in a set of elements. Let denote the average number of compar- isons required for solving the problem. We ob- tain where , which is a harmonic number. Besides, we get Key words: complexity analysis, quicksort, divide-and -conquer, generalization. 1 Introduction The quicksort algorithm has been studied by many researchers from many various view points. One of the view points is to general- ize quicksort. We shall point out three papers This research work was partially supported by the National Science Council of the Republic of China un- der NSC89-2213-E110-005. To whom all correspondence should be sent. studing the generalization. In order to reex- plain the generalization under the same base, we denote the average number of comparisons to sort elements as [2, p.278]. Then, (1) where is the numbers of elements in the first part, and is the size of the second part. Note that quicksort divides the elements into two parts. If the elements is in random order initially, then the value of is as well as . Thus, Eq.(1) can be simplified as (2) The analysis can be done for uniformly dis- tributed partitions (all probabilities have equal values). The above can be found in many articles[2, p.278][3, p.17][1, p.28]. The first generalization was proposed by Veroy[6]. He showed that the probability can be generalized as follows: Then, Eq.(1) can be simplified as 1