Assume that bubble sort is applied on the array [9,7,14,3,-7,5].
Arrange the following outputs of different passes in their correct order.
A. [-7,3,5,7,9,14]
B. [3,-7,5,7,9,14]
C. [7,3,-7,5,9,14]
D. [7,9,3,-7,5,14]
Assume that bubble sort is applied on the array [9,7,14,3,-7,5].
Arrange the following outputs of different passes in their correct order.
A. [-7,3,5,7,9,14]
B. [3,-7,5,7,9,14]
C. [7,3,-7,5,9,14]
D. [7,9,3,-7,5,14]
Solution
✅ Correct Option: 1
Bubble sort compares adjacent elements and swaps them if they are out of order, so each pass pushes the largest remaining element to the end.
D: after pass 1, the largest element 14 reaches the end:
C: after pass 2, 9 settles next to 14:
B: after pass 3, 7 settles in place:
A: after pass 4, 3 and -7 swap and the array is sorted:
Related questions:
2026: 26 May Shift 1
2026: 11 May Shift 2
2026: 18 May Shift 2