Consider an array [22, 20, 30, 10, 2, 8]. What will be the array after 2 passes of bubble sort?
Consider an array [22, 20, 30, 10, 2, 8]. What will be the array after 2 passes of bubble sort?
Solution
✅ Correct Option: 4
Each pass 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 | 22 and 20, then 30 with 10, 2 and 8 | [20, 22, 10, 2, 8, 30] |
| 2 | 22 with 10, 2 and 8 (20 and 22 are already in order) | [20, 10, 2, 8, 22, 30] |
Option 1: this is the array after only 1 pass.
Related questions:
2025: 16 May Shift 1
2025: 15 May Shift 2
2026: 26 May Shift 1
2026: 26 May Shift 1
2026: 13 May Shift 2