Consider the following array [8, 7, 13, 1, -9, 4]. After the iteration of Bubble sort, how will the array look like?
Consider the following array [8, 7, 13, 1, -9, 4]. After the iteration of Bubble sort, how will the array look like?
Solution
✅ Correct Option: 4
Each pass of Bubble sort compares adjacent pairs from the left and swaps any pair that is out of order, so the largest remaining element moves to the end.
| Pass | Swaps made | Array after the pass |
|---|---|---|
| 1 | 8-7, 13-1, 13-(-9), 13-4 | [7, 8, 1, -9, 4, 13] |
| 2 | 8-1, 8-(-9), 8-4 | [7, 1, -9, 4, 8, 13] |
| 3 | 7-1, 7-(-9), 7-4 | [1, -9, 4, 7, 8, 13] |
| 4 | 1-(-9) | [-9, 1, 4, 7, 8, 13] |
Options 1, 3 and 2 are the arrays after passes 1, 2 and 3 respectively, so each is a result of stopping too early.
Related questions:
2026: 23 May Shift 1
2025: 16 May Shift 1
2026: 19 May Shift 1
2026: 29 May Shift 1
2025: 22 May Shift 1