Skip to main contentSkip to solution

For the list [35, 9, 12, 51, 32, 21], how will the list elements look like after second pass in Bubble Sort?

Solution

✅ Correct Option: 4

Bubble sort compares adjacent elements from the left and swaps them if the left one is larger. Each pass pushes the largest remaining element to the end.

PassSwaps madeList after pass
Startnone[35, 9, 12, 51, 32, 21]
135 and 9, 35 and 12, 51 and 32, 51 and 21[9, 12, 35, 32, 21, 51]
235 and 32, 35 and 21[9, 12, 32, 21, 35, 51]

In pass 2, the pairs (9, 12) and (12, 35) need no swap. After the swaps, 35 reaches its place just before 51.

After pass kk, the last kk elements are in their final sorted positions. Here 35 and 51 are already fixed at the end.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question