Sorting Algorithms Visualized
Watch Bubble Sort, Selection Sort, and Insertion Sort in action with animated bar charts.
Step 1: What is Sorting?
Sorting means arranging items in a specific order — usually smallest to largest (ascending) or largest to smallest (descending). It is one of the most fundamental operations in computer science.
Why does sorting matter?
- Searching sorted data is much faster (e.g., binary search)
- Sorted data is easier for humans to read and analyze
- Many algorithms require sorted input to work correctly
Time Complexity tells us how an algorithm's speed scales with input size n:
- O(n²) — Simple sorts (Bubble, Selection, Insertion). Fine for small datasets, but slow for large ones.
- O(n log n) — Advanced sorts (Merge Sort, Quick Sort). Much faster for large datasets.
Below, see the difference between an unsorted and sorted array visualized as bars:
Unsorted
Sorted
About This Lab
How It Works
- 1 Read the explanation of each sorting algorithm
- 2 Click 'Sort' to watch the algorithm animate step by step
- 3 Click 'Shuffle' to reset with new random data
- 4 Compare how different algorithms perform
- 5 Complete the quiz to test your knowledge
More Labs in Algorithms
Big O Notation
AlgorithmsUnderstand algorithm efficiency — visualize O(1), O(n), O(n²), O(log n) with interactive growth charts.
Recursion
AlgorithmsUnderstand recursive thinking through visual call stacks, step-by-step tracing, and interactive examples.
Graphs & BFS/DFS
AlgorithmsExplore graph data structures and traverse them with Breadth-First and Depth-First Search animations.