Insertion Sort is O(n log n)
Michael A. Bender, Martin Farach-Colton, Miguel Mosteiro
Abstract
Traditional Insertion Sort runs in O(n2) time because each insertion takes O(n) time. When people run Insertion Sort in the physical world, they leave gaps between items to accelerate insertions. Gaps help in computers as well. This paper shows that Gapped Insertion Sort has insertion times of O(log n) with high probability, yielding a total running time of O(n log n) with high probability.
Create a lesson
Related papers
A Simple Subquadratic Cut Query Protocol for Directed Reachability
Henry Fleischmann, Sagnik Mukhopadhyay, Swagato Sanyal
Online Edge-Weighted Matching Beyond 0.55
Alireza Farhadi, Mohammad Hajiaghayi
Nonuniform Buy-at-Bulk Network Design: Improved Approximation and LP Integrality Gap
Iman Gholami, MohammadTaghi Hajiaghayi
Prophet Secretary for Matroids and XOS Valuations: A Strict Separation at 1-1/e
Hossein Esfandiari, MohammadTaghi Hajiaghayi
Deterministic Fault-Tolerant Connectivity Oracles with Subquadratic Space
Merav Parter, Elad Tzalik
The 3-Uniform Hyperclique Hypothesis is False
Timothy M. Chan, Reina Itakura, Zhiyuan Ma et al.