Mental Model
Bubble sort repeatedly swaps adjacent items if they are in the wrong order, pushing the largest unsorted item to the end each pass.
Analogy: Imagine bubbles rising in water: the biggest bubble moves up to the surface by swapping places with smaller bubbles below it.
Index: 0 1 2 3 4
Array: [5]->[3]->[8]->[4]->[2]
↑
compare adjacent pairs