Quick Sort in Java

This is a Java implementation of an earlier post named QuickSort in which I used Python. This version uses lists rather than arrays so it can be used to sort a list of any object that implements the Comparable interface. First the method which does the sorting: Followed by the main method: As per the […]

QuickSort

Quicksort uses a divide and conquer approach to sorting an array, and leverages recursion. Essentially, you pick a pivot number from the array to be sorted, it can be any number: [4, 6, 2, 1, 5] Let’s pick 2. Now partition the array into two sub-arrays, the numbers less than or equal to the pivot […]