[go: up one dir, main page]

0% found this document useful (0 votes)
22 views1 page

Text

Uploaded by

Rio Alqahtani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views1 page

Text

Uploaded by

Rio Alqahtani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Quick Sort

Quick Sort is a sorting algorithm. The algorithm picks a pivot element, rearranges
the array elements in such a way that all elements smaller than the picked pivot
element move to left side of pivot, and all greater elements move to right side.
Finally, the algorithm recursively sorts the sub-arrays on left and right of pivot
element.

There are many different choices for picking pivots:


• Always pick the first element as a pivot
• Always pick the last element as a pivot (implemented below)
• Pick a random element as a pivot
• Pick the middle as the pivot.
How its work
It works by breaking an array (partition) into smaller ones and swapping
(exchanging) the smaller ones, depending on a comparison with the 'pivot' element
picked example:

Renad hassan alqahtani


442815473

You might also like