Skip to main contentSkip to solution

Arrange the following steps in order for bubble sorting:

(A) Compare the adjacent elements.

(B) List is sorted.

(C) Take an unsorted list.

(D) Swap the elements.

Solution

✅ Correct Option: 2

(C) Take an unsorted list.

(A) Compare the adjacent elements.

(D) Swap the elements if they are in the wrong order.

(B) List is sorted.

Steps (A) and (D) repeat for every pass until no swaps are needed, and only then is the list sorted.


Option 1: declares the list sorted before the swaps that sort it are done.

Keyboard Shortcuts

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