Skip to main contentSkip to solution

After two complete passes of Bubble Sort on the array [7, 2, 9, 4], what will the new order be?

A. 7

B. 2

C. 4

D. 9

Solution

✅ Correct Option: 1

Bubble Sort compares adjacent elements and swaps them if they are in the wrong order. Each pass pushes the largest remaining element to the end.

PassComparisonsArray after pass
1(7, 2) swap, (7, 9) no swap, (9, 4) swap[2, 7, 4, 9]
2(2, 7) no swap, (7, 4) swap, (7, 9) no swap[2, 4, 7, 9]

The order is 2, 4, 7, 9, which is B, C, A, D.


Option 4: this is the array after only one pass, [2, 7, 4, 9].

Keyboard Shortcuts

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