Bubble Sort

Domain: Algorithms

🎯 Motivation

The simplest sorting algorithm to understand: repeatedly compare adjacent pairs and swap if out of order. Large values bubble to the end.

📋 Concrete Example

Pass 1 on [5, 3, 8, 1]: compare 5,3 -> swap -> [3,5,8,1]; compare 5,8 -> ok; compare 8,1 -> swap -> [3,5,1,8]. Repeat until no swaps.

🔗 Analogy

Line up students by height. The teacher walks along the line, swapping any adjacent pair where the taller is in front. After many passes, everyone is in order.