You are on page 1of 5

QUICK SORT

Earl Nino U. Alajid


ES085- K1
WHAT IS QUICK SORT
Quicksort is a highly efficient sorting technique that divides a large data array into
smaller ones. A vast array is divided into two arrays, one containing values smaller
than the provided value, say pivot, on which the partition is based. The other contains
values greater than the pivot value.
We recursively perform these three steps:
1. Bring the pivot to its appropriate position such that left of the pivot is smaller and
right is greater
2. Quick sort the left part
3. Quick sort the right part
QUICK SORT EXAMPLE
8 2 4 7 1 3 9 6 5

2 4 1 3 5 7 9 6 8

2 1 3 4 7 6 8 9

1 2 4 6 7 9

1 2 3 4 5 6 7 8 9
CODE
ADVANTAGES AND
DISADVANTAGES OF
QUICKSORT
Advantage
•Its inner loop is relatively short.
•After a thorough mathematical investigation of this algorithm, you can make a
reasonably specific statement about performance issues.
Disadvantage
•It is a recursive process. The implementation is quite tricky, mainly if recursion is
not provided.
• It is fragile in the sense that a slight error in implementation can go unreported and
cause it to function poorly.

You might also like