main page — COMP 526 Efficient Algorithms
Unit 3: Efficient Sorting
This is an archived version of this module from Spring 2022.
Click here for the current iteration.
This unit covers
- mergesort and quicksort
- counting sort
- adaptive sorting
- parallel RAM model
- parallel prefix sums
- parallel mergesort and quicksort
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.
- Understand and use the parallel random-access-machine model in its different variants.
- Be able to analyze and compare simple shared-memory parallel algorithms by determining parallel time and work.
- Understand efficient parallel prefix sum algorithms.
- Be able to devise high-level description of parallel quicksort and mergesort methods.
Material
Part I – The Basics
- Video 3-1 (2022-02-17):
§3.0 Sorting introduction
- Video 3-2 (2022-02-17):
§3.1 Mergesort
- Video 3-3 (2022-02-17):
§3.2 Quicksort
- Video 3-4 (2022-02-17):
§3.3 Comparison-based lower bound
- Video 3-5 (2022-02-17):
§3.4 Integer sorting
Part II – Exploiting presortedness
- Video 3-6 (2022-02-21):
§3.5 Adaptive sorting
- Video 3-7 (2022-02-21):
§3.6 Python’s list sort & Powersort
Part III – Sorting with many processors
- Video 3-8 (2022-02-24):
§3.7 Parallel computation, PRAM
- Video 3-9 (2022-02-24):
§3.8 Parallel primitives, prefix sum
- Video 3-10 (2022-02-24):
§3.9 Parallel sorting
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
- 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 parallel methods takes some inspiration from Uzi Vishkin’s class notes: