Q.Consider a list of 10 elements:
numList =[7,11,3,10,17,23,1,4,21,5].
Display the partially sorted list after three complete passes of Bubble sort.
Bubble sort repeatedly swaps adjacent out-of-order elements; after each complete pass the largest unsorted element "bubbles" to its correct position at the end. After three passes, the three largest numbers are in place at the right end.
Why Bubble Sort Passes?
Bubble sort works by making multiple passes through the list. In each pass, it compares adjacent elements and swaps them if they are in the wrong order. The key insight: after the first complete pass, the largest element ends up at the last position. After the second pass, the second-largest ends up at the second-last position, and so on. So after three passes, the three largest numbers are correctly placed at the end of the list.
Let's trace the passes step by step.
Initial list: [7, 11, 3, 10, 17, 23, 1, 4, 21, 5]
Pass 1 (largest element 23 bubbles to position 9)
| Comparison | Action | List after swap |
|---|---|---|
| 7 vs 11 | No swap | [7, 11, 3, 10, 17, 23, 1, 4, 21, 5] |
| 11 vs 3 | Swap | [7, 3, 11, 10, 17, 23, 1, 4, 21, 5] |
| 11 vs 10 | Swap | [7, 3, 10, 11, 17, 23, 1, 4, 21, 5] |
| 11 vs 17 | No swap | [7, 3, 10, 11, 17, 23, 1, 4, 21, 5] |
| 17 vs 23 | No swap | [7, 3, 10, 11, 17, 23, 1, 4, 21, 5] |
| 23 vs 1 | Swap | [7, 3, 10, 11, 17, 1, 23, 4, 21, 5] |
| 23 vs 4 | Swap | [7, 3, 10, 11, 17, 1, 4, 23, 21, 5] |
| 23 vs 21 | Swap | [7, 3, 10, 11, 17, 1, 4, 21, 23, 5] |
| 23 vs 5 | Swap | [7, 3, 10, 11, 17, 1, 4, 21, 5, 23] |
After Pass 1: [7, 3, 10, 11, 17, 1, 4, 21, 5, 23]
Pass 2 (second-largest 21 bubbles to position 8)
| Comparison | Action | List after swap |
|---|---|---|
| 7 vs 3 | Swap | [3, 7, 10, 11, 17, 1, 4, 21, 5, 23] |
| 7 vs 10 | No swap | [3, 7, 10, 11, 17, 1, 4, 21, 5, 23] |
| 10 vs 11 | No swap | [3, 7, 10, 11, 17, 1, 4, 21, 5, 23] |
| 11 vs 17 | No swap | [3, 7, 10, 11, 17, 1, 4, 21, 5, 23] |
| 17 vs 1 | Swap | [3, 7, 10, 11, 1, 17, 4, 21, 5, 23] |
| 17 vs 4 | Swap | [3, 7, 10, 11, 1, 4, 17, 21, 5, 23] |
| 17 vs 21 | No swap | [3, 7, 10, 11, 1, 4, 17, 21, 5, 23] |
| 21 vs 5 | Swap | [3, 7, 10, 11, 1, 4, 17, 5, 21, 23] |
After Pass 2: [3, 7, 10, 11, 1, 4, 17, 5, 21, 23]
Pass 3 (third-largest 17 bubbles to position 7)
| Comparison | Action | List after swap |
|---|---|---|
| 3 vs 7 | No swap | [3, 7, 10, 11, 1, 4, 17, 5, 21, 23] |
| 7 vs 10 | No swap | [3, 7, 10, 11, 1, 4, 17, 5, 21, 23] |
| 10 vs 11 | No swap | [3, 7, 10, 11, 1, 4, 17, 5, 21, 23] |
| 11 vs 1 | Swap | [3, 7, 10, 1, 11, 4, 17, 5, 21, 23] |
| 11 vs 4 | Swap | [3, 7, 10, 1, 4, 11, 17, 5, 21, 23] |
| 11 vs 17 | No swap | [3, 7, 10, 1, 4, 11, 17, 5, 21, 23] |
| 17 vs 5 | Swap | [3, 7, 10, 1, 4, 11, 5, 17, 21, 23] |
After Pass 3: [3, 7, 10, 1, 4, 11, 5, 17, 21, 23]
A common mistake is to stop after three comparisons rather than three complete passes. Each pass goes through the unsorted portion of the list — which shrinks by one element after each pass because the largest remaining element is already in place.
You can verify your answer by checking that the three largest numbers (23, 21, 17) are at the last three positions, and that the remaining seven elements are in some partially sorted order.
After three complete passes of Bubble sort, the partially sorted list is: [3, 7, 10, 1, 4, 11, 5, 17, 21, 23]
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.