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.

Level: beginnerTopic: Data structures algorithms

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

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.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.