Bubble Sort
QuadraticIteratively compares adjacent elements and swaps them if they are in the wrong order, causing larger elements to "bubble up" to the end of the array.
"An algorithm must be seen to be believed" — Donald Knuth
Star on GitHubGenerate or enter an array to begin
Explore the characteristics of each algorithm
Iteratively compares adjacent elements and swaps them if they are in the wrong order, causing larger elements to "bubble up" to the end of the array.
Repeatedly finds the minimum element from the unsorted portion and places it at the beginning. Simple but inefficient for large datasets.
Builds the sorted array one element at a time by repeatedly picking the next element and inserting it into its correct position.
Uses a divide-and-conquer strategy by selecting a pivot element and partitioning the array so elements less than the pivot are on the left and greater on the right.
Divides the array into halves, recursively sorts each half, and then merges the sorted halves back together. Guarantees O(n log n) in all cases.
Builds a max-heap from the array, then repeatedly extracts the maximum element and places it at the end. The heap structure enables efficient selection of the largest element.
A generalization of insertion sort that allows swapping elements far apart. Uses a gap sequence that shrinks over time, producing fascinating visual "waves" during sorting.
A non-comparison sort that counts occurrences of each value, then reconstructs the array. Extremely fast for small ranges of integer values.
Sorts numbers digit by digit from least significant to most significant using counting sort as a subroutine. Creates mesmerizing wave patterns as digits are processed.
A hybrid algorithm combining insertion sort and merge sort. Splits the array into small "runs", sorts each with insertion sort, then merges them. Used by Python and Java.