What will be the result after 3rd pass of Bubble Sort on the array [5, 1, 4, 2, 8]?
What will be the result after 3rd pass of Bubble Sort on the array [5, 1, 4, 2, 8]?
Solution
✅ Correct Option: 4
Bubble Sort compares adjacent elements in each pass and swaps them if they are out of order.
| Pass | Swaps made | Array after pass |
|---|---|---|
| 1 | ; ; | |
| 2 | ||
| 3 | none | [1, 2, 4, 5, 8] |
The array is already sorted after pass 2, so pass 3 finds nothing to swap and leaves it unchanged.
Option 3: this is the array after only the 1st pass, not the 3rd.
Related questions:
2026: 24 May Shift 1
2026: 29 May Shift 2
2026: 31 May Shift 1