Back to curriculum

Course section

Sorting Algorithms

Rearrange data using elementary, divide-and-conquer, distribution, and external sorting techniques.

10 topics
01

Sorting Foundations

Sorting algorithms are compared by time, extra space, stability, adaptiveness, and whether they operate in-place.

02

Bubble Sort

Bubble sort repeatedly swaps adjacent inversions, moving the largest remaining value to the end of each pass.

ComplexityC++ implementation Worked trace Visual lab
03

Selection Sort

Selection sort repeatedly selects the minimum remaining value and places it at the next output position.

ComplexityC++ implementation Visual lab
04

Insertion Sort

Insertion sort grows a sorted prefix by shifting larger values and inserting each new element into its correct position.

ComplexityC++ implementation Worked trace Visual lab
05

Shell Sort

Shell sort performs insertion sorts over decreasing gaps so distant inversions are removed before the final gap-one pass.

ComplexityC++ implementation
06

Merge Sort

Merge sort recursively divides the input, sorts both halves, and linearly merges the sorted results.

ComplexityC++ implementation Worked trace
07

Quick Sort

Quick sort partitions values around a pivot and recursively sorts the two resulting regions.

ComplexityC++ implementation Worked trace
08

Counting Sort

Counting sort counts occurrences of integer keys in a bounded range, avoiding comparison sorting entirely.

ComplexityC++ implementation Worked trace
09

Radix Sort

Radix sort processes keys one digit at a time using a stable sub-sort such as counting sort.

ComplexityC++ implementation Worked trace
10

External Sorting

External sorting handles data larger than RAM by sorting memory-sized runs and merging them with sequential disk access.