Computer scienceAlgorithms and Data StructuresAlgorithmsArray algorithmsSorting algorithms

Quick sort

Choosing a pivot

Report a typo

To implement the quicksort algorithm, we can use various approaches to choosing the pivot, as well as apply different partition schemes. As an example, let's consider the following array:

{ 18, 3, 15, 5, 14, 12, 11, 11, 15, 17, 19 }

If we choose the fourth element (which is 55) as the pivot, a possible partition will look as follows:

{ 3, 5, 18, 15, 14, 12, 11, 11, 15, 17, 19 }

The elements at the right of the pivot can be rearranged in any order, and it will still remain a correct partition for this pivot.

Given below is a collection of four arrays and pivots. Match each of the pivots with an array that corresponds to a correct partition for this pivot.

Match the items from left and right columns
11
15
19
17
{ 11, 11, 3, 5, 12, 15, 14, 15, 17, 19, 18 }
{ 3, 5, 11, 11, 12, 15, 14, 18, 15, 17, 19 }
{ 18, 3, 15, 5, 14, 12, 11, 11, 15, 17, 19 }
{ 3, 5, 11, 12, 11, 14, 15, 15, 18, 17, 19 }
___

Create a free account to access the full topic