Sorting Algorithm Visualizer
Watch five classic sorting algorithms work step by step. Control speed, array size, and initial arrangement. Bars turn yellow during comparisons, red during swaps, and green when sorted.
Controls
Bubble Sort
Step: 0/-1Comparisons: 0Swaps: 0
DefaultComparingSwappingSorted
Reference Guide
Bubble Sort - O(n^2)
Repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. Simple but slow for large arrays.
Selection Sort - O(n^2)
Finds the minimum element from the unsorted part and puts it at the beginning. Always makes O(n^2) comparisons but at most O(n) swaps.
Merge Sort - O(n log n)
Divides the array in half, sorts each half recursively, then merges the sorted halves. Guaranteed O(n log n) but requires extra memory.
Quick Sort - O(n log n) avg
Picks a pivot element and partitions the array around it. Average case O(n log n), worst case O(n^2), but usually the fastest in practice.
Related Content
Related Tools
Binary, Decimal & Hex Converter
Convert between binary, decimal, hexadecimal, and octal. Bit-level visualization, ASCII lookup, and step-by-step conversion methods.
Truth Table Generator
Enter Boolean expressions with AND, OR, NOT, XOR, and IMPLIES to generate complete truth tables. Detects tautologies and contradictions.
Big-O Complexity Visualizer
Compare O(1), O(log n), O(n), O(n log n), O(n^2), O(n^3), and O(2^n) on an interactive graph. See operation counts at any input size.
Logic Gate Circuit Simulator
Select predefined circuits with AND, OR, NOT, XOR, NAND, NOR gates. Toggle inputs and see outputs update in real time with auto-generated truth tables.
Related Labs
Searching & Sorting Performance Lab
Compare linear search, binary search, selection sort, insertion sort, and merge sort side by side. Animate comparisons and swaps step by step, collect performance data across array sizes, and verify O(n), O(n log n), and O(n²) complexity
Arrays & ArrayList Lab
Visualize array and ArrayList operations step by step. Trace through linear search, binary search, selection sort, insertion sort, and 2D array traversals with highlighted elements
Recursion & Data Structures Lab
Visualize recursive call stacks for factorial, fibonacci, merge sort, binary search, and tower of hanoi. Trace variable states and return values through each stack frame
Big-O & Algorithm Analysis Lab
Compare growth rates of complexity classes from O(1) to O(n!), analyze algorithm performance with best/average/worst case breakdowns, and apply the Master Theorem to divide-and-conquer recurrences