main page — COMP 526 Efficient Algorithms
Unit 3: Efficient Sorting – The Power of Divide & Conquer
This is an archived version of this module from Fall 2022.
Click here for the current iteration.
This unit covers
- mergesort and quicksort
- counting sort
- comparions lower bound for sorting
- adaptive sorting
- further divide & conquer algorithms
Learning outcomes
- Know principles and implementation of mergesort and quicksort.
- Know properties and performance characteristics of mergesort and quicksort.
- Know the comparison model and understand the corresponding lower bound.
- Understand counting sort and how it circumvents the comparison lower bound.
- Know ways how to exploit presorted inputs.
Material
Part I – The Basics
- Video 3-1 (2022-10-12):
§3.0 Sorting introduction
- Video 3-2 (2022-10-12):
§3.1 Mergesort
- Video 3-3 (2022-10-17):
§3.1 Mergesort analysis
- Video 3-4 (2022-10-17):
§3.2 Quicksort
- Video 3-5 (2022-10-19):
§3.3 Comparison-based lower bound
- Video 3-6 (2022-10-19):
§3.4 Integer sorting
Part II – Exploiting presortedness
- Video 3-7 (2022-10-19):
§3.5 Adaptive sorting & Peeksort
- Video 3-8 (2022-10-19):
§3.6 Python’s list sort & Powersort
Part III – Divide & conquer beyond sorting
- Video 3-9 (2022-10-24):
§3.7 Order statistics, quickselect, median of medians
- Video 3-10 (2022-10-24):
§3.8 Further divide & conquer algorithms
Further reading and sources
More elementary sorting methods are described in detail in Algorithms 4th ed.
The exposition of adaptive sorting is my own and based on several sources:
- Tim Peters’s description of CPython’s list.sort algorithm
- Munro, Wild: Nearly Optimal Mergesorts, ESA 2018
- Cawley Gelling, Nebel, Smith, Wild: Multiway Powersort, preprint
- Gaurav Sen: Tim sort explained,
Part 1,
Part 2,
Part 3,
Part 4.
Sequence of videos explaining Timsort’s other tricks (prior to adopting powersort’s merge rules).
The presentation of quickselect and the median-of-medians algorithm is inspired by material prepared for the module
The other material of Part III is based on