How does swapping neighbours bubble the largest element to the end, and why does a backward list push bubble sort to n squared?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
Bubble sort starts on L = [7, 3, 9, 1, 5]. Work through the first pass by hand: compare each pair of neighbours from left to right and swap any pair that is out of order. Assign the list as it stands at the end of that pass to after_pass1.