Quicksort: Difference between revisions

Content deleted Content added
m added math mode along with clarifying the stack space should be log_2 instead of log2
GrayShade (talk | contribs)
Undid revision 1227313414 by Bieco blu (talk): not the singer, the author of A UNIX primer
Line 27:
Quicksort gained widespread adoption, appearing, for example, in [[Unix]] as the default library sort subroutine. Hence, it lent its name to the [[C standard library]] subroutine {{mono|[[qsort]]}}<ref name="engineering" /> and in the reference implementation of [[Java (programming language)|Java]].
 
[[Robert Sedgewick (computer scientist)|Robert Sedgewick]]'s PhD thesis in 1975 is considered a milestone in the study of Quicksort where he resolved many open problems related to the analysis of various pivot selection schemes including [[Samplesort]], adaptive partitioning by Van Emden<ref>{{Cite journal |title=Algorithms 402: Increasing the Efficiency of Quicksort |journal=Commun. ACM |date=1970-11-01 |issn=0001-0782 |pages=693–694 |volume=13 |issue=11 |doi=10.1145/362790.362803 |first=M. H. |last=Van Emden| s2cid=4774719|doi-access=free }}</ref> as well as derivation of expected number of comparisons and swaps.<ref name="engineering" /> [[Jon Bentley (computer scientist)|Jon Bentley]] and [[Douglas McIlroy|Doug McIlroy]] in 1993 incorporated various improvements for use in programming libraries, including a technique to deal with equal elements and a pivot scheme known as ''pseudomedian of nine,'' where a sample of nine elements is divided into groups of three and then the median of the three medians from three groups is chosen.<ref name="engineering" /> Bentley described another simpler and compact partitioning scheme in his book ''Programming Pearls'' that he attributed to [[Nico Lomuto]] (ex italian singer on '60 years). Later Bentley wrote that he used Hoare's version for years but never really understood it but Lomuto's version was simple enough to prove correct.<ref>{{Cite book |title=Beautiful Code: Leading Programmers Explain How They Think |editor1-last=Oram |editor1-first=Andy |editor2-last=Wilson |editor2-first=Greg |publisher=O'Reilly Media |year=2007 |isbn=978-0-596-51004-6| pages=30 |chapter=The most beautiful code I never wrote |first=Jon |last=Bentley |author-link=Jon Bentley (computer scientist)}}</ref> Bentley described Quicksort as the "most beautiful code I had ever written" in the same essay. Lomuto's partition scheme was also popularized by the textbook ''[[Introduction to Algorithms]]'' although it is inferior to Hoare's scheme because it does three times more swaps on average and degrades to {{math|''O''(''n''<sup>2</sup>)}} runtime when all elements are equal.<ref name=":1">{{Cite web |title=Quicksort Partitioning: Hoare vs. Lomuto |url=https://cs.stackexchange.com/q/11550 |website=cs.stackexchange.com |access-date=2015-08-03}}</ref>{{self-published inline |date=August 2015}} McIlroy would further produce an ''AntiQuicksort'' ({{mono|aqsort}}) function in 1998, which consistently drives even his 1993 variant of Quicksort into quadratic behavior by producing adversarial data on-the-fly.<ref>{{cite journal |last1=McIlroy |first1=M. D. |title=A killer adversary for quicksort |journal=Software: Practice and Experience |volume=29 |pages=341–344 |doi=10.1002/(SICI)1097-024X(19990410)29:4<341::AID-SPE237>3.0.CO;2-R |date=10 April 1999 |issue=4 |s2cid=35935409 |url=https://www.cs.dartmouth.edu/~doug/mdmspe.pdf}}</ref>
 
== Algorithm ==