skip to main content
article
Free Access

Best sorting algorithm for nearly sorted lists

Published:01 November 1980Publication History
Skip Abstract Section

Abstract

Straight Insertion Sort, Shellsort, Straight Merge Sort, Quickersort, and Heapsort are compared on nearly sorted lists. The ratio of the minimum number of list elements which must be removed so that the remaining portion of the list is in order to the size of the list is the authors' measure of sortedness. Tests on randomly generated lists of various combinations of list length and small sortedness ratios indicate that Straight Insertion Sort is best for small or very nearly sorted lists and that Quickersort is best otherwise. Cook and Kim also show that a combination of the Straight Insertion Sort and Quickersort with merging yields a sorting method that performs as well as or better than either Straight Insertion Sort or Quickersort on nearly sorted lists.

References

  1. 1 Boothroyd, J. Algorithm 201: Shellsort. Comm. ACM 6, 8 (Aug. 1963), 445.Google ScholarGoogle Scholar
  2. 2 Boothroyd, J. Algorithm 207: Stringsort. Comm. ACM6, 10 (Oct. 1963), 615. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. 3 Elson, M. Data Structures. Sci. Res. Associates, Chicago, IlL, 1975. An excellent data structures textbook with a chapter on sorting.Google ScholarGoogle Scholar
  4. 4 Floyd, R.W. Algorithm 245: TREE- SORT3. Comm. ACM 7, 12 (Dec. 1964), 701. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. 5 Fredman, M.L. On computing the length of longest increasing subsequences. Discrete Math. 11 (1975), 29-35. Describes a simple algorithm using order n log n comparisons to fred the length of a longest increasing subsequence in a sequence of n distinct elements. The algorithm is also shown to be the best possible.Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. 6 Hoare, C.A.R. Algorithm 64: Quicksort. Comm. ACM 4, 7 (July 1961), 321. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. 7 Knuth, D.E. The Art of Computer Programming, Vol. 3: Sorting and Searching. Addison-Wesley, Reading, Mass., 1973. The complete reference book on sorting and searching. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 8 Loeser, R. Some performance tests of "quicksort" and descendants. Comm. A CM 17, 3 (March 1974), 143-152. Reports results of an empirical study that compared Quicksort, two of its descendants (Quickersort and qsort), Shellsort, strmgsort, and Treesort. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. 9 MacLaren, M.D. Internal sorting by radix plus sifting. J. ACM 13, 3 (July 1966), 404-- 411. Describes a sorting algorithm that is a combination of the radix and Straight Insertion Sorts. Author chose the Straight Insertion Sort because it works well "when the records are almost in order, as they will be after the radix sort." Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. 10 Martin, W.A. Sorting. Comptng. Surveys 3, 4 (Dec. 1971), 147-174. A highly recommended, readable survey of sorting algorithms. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. 11 Melhorn, K. Sorting presorted files. In Theoretical Computer Science 4th GI Conf., K. Weihrauch, Ed., Lecture Notes in Computer Science, Vol. 67, Springer-Verlag, Berlin, 1979, pp. 199-212. This article assumes a knowledge of AVL-trees. It presents a new sorting algorithm for nearly sorted lists that uses a Straight Insertion Sort for rapid insertion in an AVL-treelike data structure. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. 12 Scowen, R.S. Algorithm 271: Quickersort. Comm. ACM 8, 11 (Nov. 1965), 669-670. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. 13 vanEmden, M.H. Algorithm 402: qsort. Comm. ACM 13, I l (Nov. 1970), 693-694.Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. 14 Williams, J.W.J. Algorithm 232: Heapsort. Comm. ACM 7, 6 (June 1964), 347-348.Google ScholarGoogle Scholar

Index Terms

  1. Best sorting algorithm for nearly sorted lists
    Index terms have been assigned to the content through auto-classification.

    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 23, Issue 11
      Nov. 1980
      41 pages
      ISSN:0001-0782
      EISSN:1557-7317
      DOI:10.1145/359024
      Issue’s Table of Contents

      Copyright © 1980 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 November 1980

      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