Resource · Guide or article
Bubble Sort
Introductory description of bubble sort: repeated passes swapping adjacent out-of-order items until no swaps remain.
Reviewed
Open the original: Bubble Sort (opens the original site in a new tab)Add to a roadmap
Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.
Source content: English
Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order (ascending or descending arrangement). The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted.
PrepKit overview
PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.
- Suited to
- The source does not state a level
- Format
- Reference
What it covers
- Pass-and-swap process with an animation.
- Complexity table: best n, average and worst n squared, memory 1, stable.
How to use it
PrepKit study advice, not a claim made by the source.
Code it with an early exit when a pass makes no swaps, and explain why that gives the best case of n.
Scope and limitations
Short; no code walkthrough or exercises. Links to Wikipedia and YouTube. A Portuguese version is linked.
Access and format
English README on GitHub in trekhleb/javascript-algorithms (MIT), free.
Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 85293e3e2b88
Evidence behind this overview
- src/algorithms/sorting/bubble-sort/README.md
Pages that include this
Get the PrepKit newsletter
Optional. You don't need it to use PrepKit.