Easy · O(n²) worst, O(n) best
Bubble Sort quiz
Answer the questions in your own time, change a pick whenever you like, then hand in to see your score and why each answer is right. Nothing is saved or sent.
Questions (10)
- Viewing
- Answered
- Not answered
Bubble sort runs one pass over [5, 2, 8, 1, 7, 3, 6, 4]. What does the array look like after it?
What does every pass of bubble sort guarantee?
How many swaps does bubble sort make on [5, 2, 8, 1, 7, 3, 6, 4]?
The array [1, 2, 3, 4, 5, 6, 7, 8] is already sorted. How many comparisons does this version (with the swapped flag) make?
How many passes does the outer loop run on [1, 2, 3, 5, 4]?
Why does the listing compare with > and not >=?
What is the worst-case time complexity of bubble sort, and on what input?
Someone moves let swapped = false; above the outer loop, so it is set once. What happens?
Why is [2, 3, 4, 5, 1] slow for bubble sort, even though only one value is out of place?
How much extra memory does bubble sort use?
Progress
0 / 10 questions0%
10 questions left
Quiz details
- Total questions
- 10
- Answered
- 0
- Not answered
- 10
Take it further
- AnimationSorting
Bubble Sort Animation
The interactive version of the short video: bars that cross when they swap, a sorted tail that grows, and the early exit
Free
