CODE DRILL 1 · RUN ONLY
This is a scratch drill — your code runs, nothing is graded or recorded. No test cases, no expected output, no verdict.
TASK
Implement optimized Bubble Sort for the array [8, 5, 1, 4, 2]. Shrink the comparison boundary after each pass, stop after a pass with no swaps, and print the array after every completed pass.
OUTPUT
Sample[5, 1, 4, 2, 8] [1, 4, 2, 5, 8] [1, 2, 4, 5, 8] [1, 2, 4, 5, 8]
What a finished answer prints, from the lesson. Nothing has run yet — press Run and this is replaced by your program’s own output.