DSA Lab
Sorting race
The race runs six algorithms on the same input and counts one unit of work (a comparison, swap or write) per tick, so you can see how the input's shape changes the winner.
Sorting race: how it works
In this tool: six algorithms, side by side. Put in your own values and watch it change. Each operation runs one step at a time and says in plain words what happened, with its calculation worked out. The code is shown in Python, C, C++ or Java with the line that just ran marked, and an Understand it panel gives the idea, why it works, the cost of each operation, common mistakes and a short quiz.
Lessons that use it
- Sorting algorithms (Python)Watch bubble sort and selection sort move values, then sort anything with sorted() and a key.
- Bubble, selection and insertion sort (Algorithms)Three O(n²) sorts, step by step: swapping neighbours, picking the minimum, and inserting into a sorted part.
- Merge sort (Algorithms)Divide and conquer: split the array in half, sort each half recursively, and merge two sorted halves in O(n).
- Quick sort (Algorithms)Partition around a pivot, sort each side recursively; O(n log n) on average, O(n²) when the pivots are bad.