← 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?
- A.[1, 2, 4, 5, 8]
- B.[1, 4, 2, 5, 8]
- C.[1, 5, 4, 2, 8]
- 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 →