Interactive animations
 

Interactive animations

for teaching algorithms and programming

 

Quicksort

This animation shows how quicksort works. First we choose a pivot (middle element). Next, we swap
the elements in the beginning of the array with the elements in the end, until in the beginning of
the array will be only those elements, which are less or equal than the pivot; and in the end of
the array will remain only those elements, which are greater or equal than the pivot. Finally, if
in the beginning or in the end is more than one element, we repeat the whole process for those parts.

Mergesort

This animation shows how mergesort works. First, we devide the array to two parts, then to another
two parts, until we get parts with one element only. These 1-element parts are sorted. Next, we
merge these 1-element parts to a 2-element part. When we have two sorted 2-element parts, we
merge them to a 4-element part. Finally, we merge the two 4-element parts to get the sorted array.


 
(C) 2012-2020, Ladislav Végh, Komárno, Slovakia