AI engineering glossary · Data structures algorithms
What is insertion sort?
Insertion sort: A sorting method that builds a sorted section one item at a time, inserting each new item into its correct place among the already sorted ones. It takes O(n^2) in general but is fast on nearly sorted data and small inputs.
Insertion sort: an example
Sorting playing cards in your hand by picking up one card at a time and sliding it into the right spot is insertion sort.
Related terms
More Data structures algorithms terms
- Interval scheduling
- Kadane's algorithm
- Knapsack problem
- Knuth-Morris-Pratt algorithm
- Kruskal's algorithm
- Linear search
- Linked list
- Load factor
Where you learn it
Insertion sort is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.