×
Welcome!
Just Press Start!
This application shows the comparative speed and logic of three
popular sort algorithms with arrays of length N filled with
the positive integers 1 to N + 1. Each bar represents an element of the array
and its height represents the element's value. Just press start or first
specify the number of elements in the array, how out of order they
are and how fast the animation goes.
Bubble sort is a solution many naive programmers
begin with. Compare every element to its neighbor and switch
if needed. However that takes a lot of time and with large data sets
becomes unmanageable. Merge sort takes the approach of divide and conquer
by sorting sections of the array one at a time. However this causes
the need for an auxiliary "sorted" array.
In place quick sort can be faster than merge sort - or as slow
as bubble sort - depending on its initial state and pivot choice
but on average it is the same speed as merge sort with out the
need for extra space.