Merge Sort
Merge two sorted runs by always taking the smaller front value.
Merge Sort: Eight values
1 is smaller than 5, so 1 is written to index 0.
Cost
- Best
- O(n log n)
- Average
- O(n log n)
- Worst
- O(n log n)
- Space
- O(n)
Properties
- Yes: Comparison based
- Yes: Stable
- No: In place
- No: Adaptive
- No: Online
Before this
Related
Leads to
Topics that need this one first.
Taught by the same lesson
Merge Sort covers these too, in the same run.