Skip to main contentSkip to solution

What will be the result after second pass of bubble sort for an unsorted list given as follows?

[8,7,13,1,-9,4]

Solution

✅ Correct Option: 2

Each pass compares adjacent pairs from the left and swaps them if they are out of order, so the largest remaining element moves to the end.

PassSwaps madeList after the pass
18,78,7; 13,113,1; 13,−913,-9; 13,413,4[7,8,1,-9,4,13]
28,18,1; 8,−98,-9; 8,48,4[7,1,-9,4,8,13]

In pass 2, the pair 7,87,8 is already in order, so there is no swap there.


Option 1: this is the list after the first pass, not the second.

Options 3 and 4: these need three or more passes, so they are too far along.

Keyboard Shortcuts

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