What does the array look like after the first pass of bubble sort in ascending order?
Correct answer D. [3, 7, 1, 5, 9]
Explanation
One pass compares adjacent pairs from left to right and swaps any that are out of order: 7 and 3 swap, 7 and 9 stay, 9 and 1 swap, then 9 and 5 swap, giving [3, 7, 1, 5, 9]. After each pass the largest remaining value has bubbled to its final position at the end; the array is not fully sorted after one pass.
Answer checked How we write and check questions
Discussion