AI engineering glossary · Data structures algorithms
What is bubble sort?
Bubble sort: A simple sorting method that repeatedly steps through the list, swapping adjacent items that are in the wrong order, until no swaps are needed. It takes O(n^2) time and is used mainly for teaching.
Bubble sort: an example
On [5, 1, 4], one pass swaps 5 and 1, then 5 and 4, giving [1, 4, 5].
Related terms
More Data structures algorithms terms
- Call stack
- Circular buffer
- Coin change problem
- Collision
- Comparison sort
- Connected components
- Consistent hashing
- Counting sort
Where you learn it
Bubble sort is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.