Skip to main contentSkip to solution

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.

PassSwaps madeArray after the pass
122 and 20, then 30 with 10, 2 and 8[20, 22, 10, 2, 8, 30]
222 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.

Keyboard Shortcuts

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