AI engineering glossary · Data structures algorithms
What is merge sort?
Merge sort: A divide and conquer sorting method that splits the list in half, sorts each half recursively and then merges the two sorted halves. It runs in O(n log n) time in every case, is stable and needs O(n) extra memory.
Merge sort: an example
Sorting [8, 3, 5, 1]: split into [8, 3] and [5, 1], sort each to [3, 8] and [1, 5], then merge to [1, 3, 5, 8].
Related terms
More Data structures algorithms terms
- Minimum spanning tree
- Monotonic stack
- NP-complete
- Open addressing
- Optimal substructure
- Overlapping subproblems
- P versus NP
- Polynomial time
Where you learn it
Merge 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.