SUMMARYQuicksort is the preferred in-place sorting algorithm in many contexts, since its average computing time on uniformly distributed inputs is Θ (N log N), and it is in fact faster than most other sorting algorithms on most inputs. Its drawback is that its worst-case time bound is Θ(N 2 . Previous attempts to protect against the worst case by improving the way quicksort chooses pivot elements for partitioning have increased the average computing time too much -one might as well use heapsort, which has a Θ(N log N) worst-case time bound, but is on the average 2-5 times slower than quicksort. A similar dilemma exists with selection algorithms (for finding the i-th largest element) based on partitioning. This paper describes a simple solution to this dilemma: limit the depth of partitioning, and for subproblems that exceed the limit switch to another algorithm with a better worst-case bound. Using heapsort as the 'stopper' yields a sorting algorithm that is just as fast as quicksort in the average case, but also has an Θ(N log N) worst case time bound. For selection, a hybrid of Hoare's FIND algorithm, which is linear on average but quadratic in the worst case, and the Blum-Floyd-Pratt-Rivest-Tarjan algorithm is as fast as Hoare's algorithm in practice, yet has a linear worst-case time bound. Also discussed are issues of implementing the new algorithms as generic algorithms, and accurately measuring their performance in the framework of the C++ Standard Template Library.
The eq~ational,axioms of an algebraic speciflcatlort of a data type (such as flnlte sequences) often can be formed into a convergent sot of rewrite rules; Le. such that all sequences of rewrites are finite and unlque{y termhtatlng, If one adds [
This document is approved for public release and sale; distribution unlimited. 17. DISTRIBUTION STATEMENT (ol lh» mbrntrmcl wnttfd In Block 30, II illlfmfnt Intn Rmpari) K'-'X')-/>-DHHC/^-^-^-~^3 18. SU9*L«MENTARY NOTES ^L fi/ZrhJ-Sa^'^rnL* tZL-^S 1>. KEY WORDS rConllnu» on fvnmo tldt II nmcttttry mxd IdmnUly by block numbor) abstract data type, correctness proof, data type, data structure, specification, software specification 20. ABSTRACT (Conllnut en nvormo «id« 1/ n^^^ttmry mud Idomlly hy block mmbtt)
scite is a Brooklyn-based organization that helps researchers better discover and understand research articles through Smart Citations–citations that display the context of the citation and describe whether the article provides supporting or contrasting evidence. scite is used by students and researchers from around the world and is funded in part by the National Science Foundation and the National Institute on Drug Abuse of the National Institutes of Health.