Skip to main contentSkip to solution

What will be status of the array [8, 7, 13, 1, -9, 4], after the third pass of Bubble sort?

Solution

✅ Correct Option: 3

Bubble sort (ascending) compares adjacent elements and swaps them if they are out of order. After each pass, the largest remaining element settles at the end.

PassSwaps madeArray after pass
18,78,7; 13,113,1; 13,−913,-9; 13,413,4[7,8,1,−9,4,13][7, 8, 1, -9, 4, 13]
28,18,1; 8,−98,-9; 8,48,4[7,1,−9,4,8,13][7, 1, -9, 4, 8, 13]
37,17,1; 7,−97,-9; 7,47,4[1,−9,4,7,8,13][1, -9, 4, 7, 8, 13]

Option 1: this is the array after the first pass, not the third.

Option 2: this is the original, unsorted array.

Keyboard Shortcuts

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