The quick sort in action

Let's take a look at the quick sort algorithm in action step by step:

Given the [3, 5, 1, 6, 4, 7, 2] array, the preceding diagram represents the first execution of the partition operation.

The following diagram exemplifies the execution of the partition operation for the first subarray of lower values (note that 7 and 6 are not part of the subarray):

Next, we will continue creating subarrays, as seen in the following diagram, but now with greater values than the subarray of the preceding diagram (the lower subarray ...

Get Learning JavaScript Data Structures and Algorithms - Third Edition 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.