🎙 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 12 of 13

Why is the largest value always at the end after the first pass of bubble sort?

Why is the largest value always at the end after the first pass of bubble sort?

  1. A.Bubble sort starts by finding the maximum with a separate loop
  2. B.Once the pass reaches the largest value, it wins every comparison and is swapped right until the end
  3. C.Because the array is reversed before sorting
  4. D.It is not; the largest value can be anywhere
Answer & explanation

Correct answer: Once the pass reaches the largest value, it wins every comparison and is swapped right until the end

That is why each later pass can stop one position earlier.

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 →