Online sorts | Stable sorts | Comparison sorts | Sorting algorithms

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 their 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 they find the correct space in the B section, they 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 they were to leave a space after every letter, as long as there was still space after B, they would only have to move a few books to make room for the new one. This is the basic principle of the Library Sort. The algorithm was proposed by Michael A. Bender, Martín Farach-Colton, and in 2004 and was published in 2006. Like the insertion sort it is based on, library sort is a comparison sort; 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). There is no full implementation given in the paper, nor the exact algorithms of important parts, such as insertion and rebalancing. Further information would be needed to discuss how the efficiency of library sort compares to that of other sorting methods in reality. Compared to basic insertion sort, the drawback of library sort is that it requires extra space for the gaps. The amount and distribution of that space would be implementation dependent. In the paper the size of the needed array is (1 + ε)n, but with no further recommendations on how to choose ε. Moreover, it is neither adaptive nor stable. In order to warrant the with-high-probability time bounds, it requires to randomly permute the input, what changes the relative order of equal elements and shuffles any presorted input. Also, the algorithm uses binary search to find the insertion point for each element, which does not take profit of presorted input. Another drawback is that it cannot be run as an online algorithm, because it is not possible to randomly shuffle the input. If used without this shuffling, it could easily degenerate into quadratic behaviour. One weakness of insertion sort is that it may require a high number of swap operations and be costly if memory write is expensive. Library sort may improve that somewhat in the insertion step, as fewer elements need to move to make room, but is also adding an extra cost in the rebalancing step. In addition, locality of reference will be poor compared to mergesort as each insertion from a random data set may access memory that is no longer in cache, especially with large data sets. (Wikipedia).

Video thumbnail

Heap Sort - Intro to Algorithms

This video is part of an online course, Intro to Algorithms. Check out the course here: https://www.udacity.com/course/cs215.

From playlist Introduction to Algorithms

Video thumbnail

Insertion Sort Algorithm

Visual description of the insertion sort algorithm

From playlist Computer Science

Video thumbnail

Access 2007: Sorting Records

In this video, you’ll learn more about sorting records in Access 2007. Visit https://www.gcflearnfree.org/access2007/sorting-records/1/ for our text-based lesson. This video includes information on: • Sorting records on text values • Sorting records on numerical values • Clearing a sort

From playlist Microsoft Access 2007

Video thumbnail

Selection Sort Algorithm

This presentation discusses the selection sort algorithm. Before writing code students should be able to sort an array on paper and show how the array is reorganized after each iteration of the selection sort algorithm. See my web link below. – – – – – – – – – – – – – – – –

From playlist Java Programming

Video thumbnail

Java Sort Algorithm

Get the Code Here: http://goo.gl/O8184l Welcome to my Java sort algorithm tutorial. Here I will cover all of the elementary sorting algorithms : Bubble, Selection and Insertion sort. I also created a new method we can use to analyze the arrays so we can learn how the sorts work. I want t

From playlist Java Algorithms

Video thumbnail

How to Sort a Python Dictionary By Value or Key!

Sentdex.com Facebook.com/sentdex Twitter.com/sentdex How to sort a dictionary within python, by key or value, even though the critics say it is not possible!

From playlist Intermediate Python Tutorials

Video thumbnail

Live CEOing Ep 678: Language Design Review of Foreign Function Interface Functionality continued

In this episode of Live CEOing, Stephen Wolfram discusses upcoming improvements and features to the Wolfram Language. If you'd like to contribute to the discussion in future episodes, you can participate through this YouTube channel or through the official Twitch channel of Stephen Wolfram

From playlist Behind the Scenes in Real-Life Software Design

Video thumbnail

OSB 2015 - The Public Library As An (Almost) Open Source Institution - Alex Byrne

Your public library can be one of your best allies for creating, distributing, and promoting Open Source ideas and projects. They want to help - they just need to know how.

From playlist Open Source Bridge 2015

Video thumbnail

Library 2.0 Panel 2, Part 1: Ethics and Politics of Library 2.0

The Yale Information Society Project (ISP) hosted the Library 2.0 Symposium on Saturday, April 4, 2009, at Yale Law School. The symposium was especially timely as the confluence of book digitization projects, user-generated content, and social networking applications forces us to rethink t

From playlist The Yale ISP Library 2.0 Symposium

Video thumbnail

Live CEOing Ep 675: Language Design Review of Foreign Function Interface Functionality

In this episode of Live CEOing, Stephen Wolfram discusses upcoming improvements and features to the Wolfram Language. If you'd like to contribute to the discussion in future episodes, you can participate through this YouTube channel or through the official Twitch channel of Stephen Wolfram

From playlist Behind the Scenes in Real-Life Software Design

Video thumbnail

Library 2.0 Panel 4, Part 2: Digitizing Collections

The Yale Information Society Project (ISP) hosted the Library 2.0 Symposium on Saturday, April 4, 2009, at Yale Law School. The symposium was especially timely as the confluence of book digitization projects, user-generated content, and social networking applications forces us to rethink t

From playlist The Yale ISP Library 2.0 Symposium

Video thumbnail

DreamCoder: Growing generalizable, interpretable knowledge with wake-sleep Bayesian program learning

#dreamcoder #programsynthesis #symbolicreasoning Classic Machine Learning struggles with few-shot generalization for tasks where humans can easily generalize from just a handful of examples, for example sorting a list of numbers. Humans do this by coming up with a short program, or algori

From playlist Papers Explained

Video thumbnail

Calling External Libraries with the Compiler

Learn about new features of the Wolfram Language compiler that make it possible to efficiently interact with external libraries. LibraryFunctionDeclaration makes it possible to call library functions in compiled Wolfram Language code, while functions like ToRawPointer, CreateTypeInstance a

From playlist Wolfram Technology Conference 2022

Video thumbnail

Library 2.0 Panel 2, Part 2: Ethics and Politics of Library 2.0

The Yale Information Society Project (ISP) hosted the Library 2.0 Symposium on Saturday, April 4, 2009, at Yale Law School. The symposium was especially timely as the confluence of book digitization projects, user-generated content, and social networking applications forces us to rethink t

From playlist The Yale ISP Library 2.0 Symposium

Video thumbnail

Library 2.0 Panel 1, Part 1: The Future of the Library

The Yale Information Society Project (ISP) hosted the Library 2.0 Symposium on Saturday, April 4, 2009, at Yale Law School. The symposium was especially timely as the confluence of book digitization projects, user-generated content, and social networking applications forces us to rethink t

From playlist The Yale ISP Library 2.0 Symposium

Video thumbnail

Improved Workflow With Isolated Jupyter Environments - Colin Carroll

Subscribe to O'Reilly on YouTube: http://goo.gl/n3QSYi Follow O'Reilly on: Twitter: http://twitter.com/oreillymedia Facebook: http://facebook.com/OReilly Instagram: https://www.instagram.com/oreillymedia LinkedIn: https://www.linkedin.com/company-beta/8459/

From playlist The O’Reilly Jupyter Pop-up

Video thumbnail

Discrete Math - 3.1.3 Sorting Algorithms

Bubble sort and insertion sort algorithms. Textbook: Rosen, Discrete Mathematics and Its Applications, 7e Playlist: https://www.youtube.com/playlist?list=PLl-gb0E4MII28GykmtuBXNUNoej-vY5Rz

From playlist Discrete Math I (Entire Course)

Related pages

Online algorithm | Sorting algorithm | Comparison sort | Insertion sort | Quicksort