Algorithms and Data Structures · Junior · Question 39 of 75
How does bubble sort work?
- 1It picks a pivot and partitions the array around it
- ✓Correct answer: It repeatedly swaps adjacent elements that are in the wrong order
- 3It splits the array in half, sorts both halves and merges them
Explanation
After each pass the largest remaining element "bubbles" to the end. It's O(n²) and is mainly used for teaching. Splitting and merging is merge sort; partitioning around a pivot is quicksort.