Skip to content
Discussion options

You must be logged in to vote

For nearly-sorted input, insertion sort (O(n) best case) outperforms the general-purpose O(n log n) sorts here since it adapts to existing order — quicksort/mergesort pay their full O(n log n) cost regardless of initial ordering.

Replies: 1 comment

Comment options

Kubomu
Jul 11, 2026
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by Kubomu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant