TimSort
Find natural ascending runs, extend short ones by insertion sort, then merge neighbouring runs.
More Sorts: Timsort finds two natural runs
From index 0 the values keep rising for 5 slots: a natural run of length 5. That is at least 4, so it is taken as it is.
Cost
- Best
- O(n)
- Average
- O(n log n)
- Worst
- O(n log n)
- Space
- O(n)
Properties
- Yes: Comparison based
- Yes: Stable
- No: In place
- Yes: Adaptive
- No: Online
Before this
Taught by the same lesson
More Sorts covers these too, in the same run.