Quick sort

Quick sort is also known as partition exchange sort. It was developed by Tony Hoare. Quick sort also utilizes the power of divide and conquer, which we came to understand in the previous section. It is just about dividing a problem into approximately similar sub problems, solving each sub problem separately, and combining the results of the sub problems to deliver the final result.

Quick sort steps can be laid out in following fashion:

  1. We select a pivot element. Selecting a proper pivot is very necessary for efficiency in a quick sort algorithm.
  2. We put the pivot element in such a location that all the elements on its left are less than the pivot element, and all the elements on its right are greater than the pivot. This way, we partition ...

Get Learning Functional Data Structures and Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.