Library sort

Library sort

Library sort, or gapped insertion sort is a sorting algorithm that uses an insertion sort, but with gaps in the array to accelerate subsequent insertions. The name comes from an analogy:

:"Suppose a librarian were to store his books alphabetically on a long shelf, starting with the As at the left end, and continuing to the right along the shelf with no spaces between the books until the end of the Zs. If the librarian acquired a new book that belongs to the B section, once he finds the correct space in the B section, he will have to move every book over, from the middle of the Bs all the way down to the Zs in order to make room for the new book. This is an insertion sort. However, if he were to leave a space after every letter, as long as there was still space after B, he would only have to move a few books to make room for the new one. This is the basic principle of the Library Sort."Fact|date=March 2008

The algorithm was proposed by Michael A. Bender, Martín Farach-Colton, and Miguel Mosteiro in 2004. Like the insertion sort it is based on, library sort is a stable comparison sort and can be run as an online algorithm; however, it was shown to have a high probability of running in O(n log n) time (comparable to quicksort), rather than an insertion sort's O(n2). Its implementation is very similar to a skip list. The drawback to using the library sort is that it requires extra space for its gaps (the extra space is traded off against speed).

References

* [http://citeseer.ist.psu.edu/bender04insertion.html Original publication at Citeseer]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Sort (C++) — sort is a function in C++ Standard Template Library that takes two random access iterators, the start and the end, as arguments and performs a comparison sort on the range of elements between the two iterators, front inclusive and end exclusive.… …   Wikipedia

  • Sort — may mean * Sorting, any process of arranging items in sequence or in sets ** In conveyor lines sortage is the term for a checkweigher sorting products. ** Sorting algorithm, a computer process for arranging elements in lists ** Sort (Unix), a… …   Wikipedia

  • Library catalog — A library catalog (or library catalogue) is a register of all bibliographic items found in a library or group of libraries, such as a network of libraries at several locations. A bibliographic item can be any information entity (e.g., books,… …   Wikipedia

  • Library of America — The Library of America (LoA) is a nonprofit publisher of classic American literature. Overview and history Founded in 1979 with seed money from the National Endowment for the Humanities and the Ford Foundation, the LoA has published more than 150 …   Wikipedia

  • Library of Alexandria — For the modern library, see Bibliotheca Alexandrina. This Latin inscription regarding Tiberius Claudius Balbilus of Rome (d. c. AD 79) mentions the ALEXANDRINA BYBLIOTHECE (line eight).. The Royal Library of Alexandria, or Ancient Library of… …   Wikipedia

  • SORT — The Treaty Between the United States of America and the Russian Federation on Strategic Offensive Reductions (SORT), better known as the Moscow Treaty represents an important element of the new strategic relationship between the United States and …   Wikipedia

  • Sort (typesetting) — Diagram of a cast metal sort. a face, b body or shank, c point size, 1 shoulder, 2 nick, 3 groove, 4 foot …   Wikipedia

  • Merge sort — Example of merge sort sorting a list of random dots. Class Sorting algorithm Data structure Array Worst case performance O(n log n) …   Wikipedia

  • Insertion sort — Infobox Algorithm class=Sorting algorithm data=Array time= О(n²) space= О(n) total, O(1) auxiliary optimal=Not usuallyInsertion sort is a simple sorting algorithm, a comparison sort in which the sorted array (or list) is built one entry at a time …   Wikipedia

  • Counting sort — In computer science, counting sort is an algorithm for sorting a collection of objects according to keys that are small integers; that is, it is an integer sorting algorithm. It operates by counting the number of objects that have each distinct… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”