Skip to main contentSkip to solution

Apply bubble sort technique to sort a list of elements:

numList2 = [8, 7, 6, 5, 4]. Show the positions of elements in the list after pass 1.

Solution

✅ Correct Option: 3

In pass 1, bubble sort compares each adjacent pair from left to right and swaps them if the left one is larger. This carries the largest element, 8, to the last position.

ComparisonList after comparison
Start8 7 6 5 4
8 and 7: swap7 8 6 5 4
8 and 6: swap7 6 8 5 4
8 and 5: swap7 6 5 8 4
8 and 4: swap7 6 5 4 8

Option 4: this is the list after only 3 of the 4 comparisons, so pass 1 is not complete.

Option 2: this is the fully sorted list, which needs 4 passes for this input, not 1.

After pass kk, the kk largest elements are in their final positions at the end of the list.

Keyboard Shortcuts

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