skip to main content
article
Free Access

Implementing Quicksort programs

Published:01 October 1978Publication History
Skip Abstract Section

Abstract

This paper is a practical study of how to implement the Quicksort sorting algorithm and its best variants on real computers, including how to apply various code optimization techniques. A detailed implementation combining the most effective improvements to Quicksort is given, along with a discussion of how to implement it in assembly language. Analytic results describing the performance of the programs are summarized. A variety of special situations are considered from a practical standpoint to illustrate Quicksort's wide applicability as an internal sorting method which requires negligible extra storage.

References

  1. 1 Boothroyd, J. Sort of a section of the elements of an array by determining the rank of each element: Algorithm 25; and Ordering the subscripts of an array section according to the magnitudes of the elements: Algorithm 26. Comptr. J. 10 (Nov. 1967), 308-310. (See notes by R.S. Scowen in Comptr. J. 12 (Nov. 1969), 408-409, and by A.D. Woodall in Comptr. J. 13 (Aug. 1970.)Google ScholarGoogle Scholar
  2. 2 Brawn, B.S., Gustavson, F.G., and Mankin, E. Sorting in a paging environment. Comm. ACM 13, 8 (Aug. 1970), 483-494. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. 3 Cocke, J., and Schwartz, J.T. Programming languages and their compilers. Preliminary Notes. Courant Inst. of Math. Sciences, New York U., New York, 1970. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. 4 Frazer, W.D., and McKellar, A.C. Samplesort: A sampling approach to minimal storage tree sorting. J. ACM 17, 3 (July 1970), 496-507. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. 5 Hoare, C.A.R. Partition: Algorithm 63; Quicksort: Algorithm 64; and Find: Algorithm 65. Comm. ACM 4, 7 (July 1961), 321-322. (See also certification by J.S. Hillmore in Comm. ACM 5, 8 (Aug. 1962), 439, and B. Randell and L.J. Russell in Comm. A CM 6, 8 (Aug. 1963), 446.) Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. 6 Hoare, C.A.R. Quicksort. Computer J. 5, 4 (April 1962), 10-15.Google ScholarGoogle ScholarCross RefCross Ref
  7. 7 Knuth, D.E. The Art of Computer Programming, VoL 1: Fundamental Algorithms. Addison-Wesley, Mass., 1968. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 8 Knuth, D.E. The Art of Computer Programming, Vol. 2: Seminumerical Algorithms. Addison-Wesley, Mass., 1969. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. 9 Knuth, D.E. The Art of Computer Programming, Vol. 3: Sorting and Searching. Addison-Wesley, Mass., 1972. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. 10 Knuth, D.E. Structured programming with go to statements. Computing Surveys 6, 4 (Dec. 1974), 261-301. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. 11 Loeser, R. Some performance tests of "quicksort" and descendants. Comm. ACM 17, 3 (March 1974), 143-152. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. 12 Morris, R. Some theorems on sorting. SlAM J. Appl. Math. 17, 1 (Jan. 1969), I-6.Google ScholarGoogle ScholarCross RefCross Ref
  13. 13 Rich, R.P. Internal Sorting Methods Illustrated with PL/I Progams. Prentice-Hall, Englewood Cliffs, N.J., 1972.Google ScholarGoogle Scholar
  14. 14 Scowen, R.S. Quickersort: Algorithm 271. Comm. ACM 8, 11 (Nov. 1965), 669-670. (See also certification by C.R. Blair in Comm. ACM 9, 5 (May 1966), 354.) Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. 15 Sedgewick, R. Quicksort. Ph.D. Th. Stanford Comptr. Sci. Rep. STAN-CS-75-492, Stanford U., Stanford, Calif., May 1975.Google ScholarGoogle Scholar
  16. 16 Sedgewick, R. Quicksort with equal keys. Siam J. Comput. 6, 2 (June 1977), 240-287.Google ScholarGoogle ScholarCross RefCross Ref
  17. 17 Sedgewick, R. The analysis of Quicksort programs. Acta Informatica 7 (1977), 327-355.Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. 18 Singleton, R.C. An efficient algorithm for sorting with minimal storage: Algorithm 347. Comm. ACM 12, 3 (March 1969), 185-187. (See also remarks by R. Griffin and K.A. Redish in Comm. ACM 13, l (Jan. 1970), 54 and by R. Peto, Comm. ACM 13, l0 (Oct. 1970), 624.) Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. 19 Stone, H.S. Sorting on STAR. IEEE Trans. Software Eng. SE-4, 2 (Mar. 1978), 138-146.Google ScholarGoogle Scholar
  20. 20 van Emaen, M.N. Increasing the efficiency of quicksort: Algorithm 402. Comm. ACM 13, 11 (Nov. 1970), 693-694. (See also the article by the same name in Comm. ACM 13, 9 (Sept. 1970), 563-567.) Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. 21 Wirth, N. Algorithms + Data Structures = Programs. Prentice- Hall, Englewood Cliffs, N.J., 1976. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Implementing Quicksort programs

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image Communications of the ACM
        Communications of the ACM  Volume 21, Issue 10
        Oct. 1978
        76 pages
        ISSN:0001-0782
        EISSN:1557-7317
        DOI:10.1145/359619
        Issue’s Table of Contents

        Copyright © 1978 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 1 October 1978

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader