• # Quicksort

General and Gameplay Programming

Now that we visit a recursive sorting algorithm. This algorithm involves moving a data, called pivot. The algorithm then partitions the array into two parts by moving the pivot into its correct position, so that items to the pivot's left are smaller then the pivot, and the items to the right are bigger.The algorithm then is called recursively so that it will partition the two subordinate arrays on either side of the pivot until the entire array is sorted.

Below is the pseudo-code of Quick Sort.

Quick Sort (Sorting array A[size])

While Low is less than High
{
Choose Pivot as the element at position A[Low]
While A[High] is greater than Pivot, decrement High; else move A[High] to A[Low]
While A[Low] is less than Pivot, increment Low; else move A[Low] to A[High]
}
Move Pivot into A[High], see Pivot position as High.
If Low is less than Pivot point, recursively call Quick Sort with Low =
Low, High = Pivot point - 1
If High is greater than Pivot point, recursively call Quick Sort with Low =
Pivot point + 1, High = High.

Report Article

## User Feedback

There are no comments to display.

## Create an account

Register a new account

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 0
• 0
• 0
• 4

• 11
• 15
• 21
• 26
• 11
×