Insertion Sort is O(n log n)
Abstract
Traditional Insertion Sort runs in O(n^2) 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.
- Publication:
-
arXiv e-prints
- Pub Date:
- July 2004
- DOI:
- 10.48550/arXiv.cs/0407003
- arXiv:
- arXiv:cs/0407003
- Bibcode:
- 2004cs........7003B
- Keywords:
-
- Computer Science - Data Structures and Algorithms;
- E.5;
- F.2.2
- E-Print:
- 6 pages, Latex. In Proceedings of the Third International Conference on Fun With Algorithms, FUN 2004