Skip to main contentSkip to solution

In the following list, bubble sort technique has been applied to sort a list of elements.

numList2 = [8, 7, 6, 5, 4]

Arrange the list after each pass in order :

(A) [7, 6, 5, 4, 8]

(B) [5, 4, 6, 7, 8]

(C) [8, 7, 6, 5, 4]

(D) [6, 5, 4, 7, 8]

Solution

✅ Correct Option: 2

Bubble sort compares adjacent elements and swaps them if they are in the wrong order. After each pass, the largest remaining element settles at the end.

(C) [8, 7, 6, 5, 4]: the original list, before any pass.

(A) [7, 6, 5, 4, 8]: after pass 1, 8 has moved to the end.

(D) [6, 5, 4, 7, 8]: after pass 2, 7 has moved to its place.

(B) [5, 4, 6, 7, 8]: after pass 3, 6 has moved to its place.

After pass 4 the list becomes [4, 5, 6, 7, 8].

Keyboard Shortcuts

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