Quicksort
This is a simulation of the Quicksort
sorting algorithm. We start with an array of bars
and sort them according to their height in ascending
order. References taken from a coding challenge by
The Coding Train.
Quicksort is a divide-and-conquer algorithm: it
performs sorting by dividing the original array into
smaller subarrays and solving them independently,
loosely speaking. It involves picking an element of
the array as the pivot element and partitioning the
given array around the picked pivot.
Partitioning refers to arranging the given array(or
subarray) in such a way that all elements to the left
of the pivot element are smaller than it and all
elements to its right are larger than it. Thus, we have
a reference point from where we proceed to sort the
left and right 'halves' of the array, and eventually
arrive at an array sorted in ascending order.
More