Bubble Sort
Learn about bubble sort, an introductory sorting algorithm that iterates through a list and compares pairings of adjacent elements.
StartKey Concepts
Review core concepts you need to learn to master this subject
Bubble Sort Algoritm
Bubble Sort Big-O Runtime
Bubble Sort Swapping Variables
Swapping Variables in Bubble Sort
Python Swap Function
Bubble Sort Algoritm
Bubble Sort Algoritm
The Bubble Sort algorithm is a simple algorithm to sort a list of N numbers in ascending order. Bubble sort works by iterating through a list and checking whether the current element is larger or smaller than the next element.
This algorithm consists of an outer iteration and an inner iteration. In the inner iteration, the first and second elements are first compared and swapped so that the second element has a higher value than the first. This is repeated for the subsequent second and third element pairs and so forth until the last pair of (N-2, N-1) elements is compared. At the end of the inner iteration, the largest element appears last. This is repeated for all elements of the list in the outer iteration.
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory