🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Sorting Basics: all 13 questions

Quiz: Sorting Basics · Question 7 of 13

After the FIRST pass of bubble sort on [5, 1, 4, 2, 8], what is the array?

After the FIRST pass of bubble sort on [5, 1, 4, 2, 8], what is the array?

  1. A.[1, 2, 4, 5, 8]
  2. B.[1, 4, 2, 5, 8]
  3. C.[1, 5, 4, 2, 8]
  4. D.[5, 1, 4, 2, 8]
Answer & explanation

Correct answer: [1, 4, 2, 5, 8]

The pass swaps 5 with 1, then 4, then 2, carrying 5 forward until it stops before 8.

Can you get the rest right without peeking?

Take the timed Quiz: Sorting Basics quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →