Efficient implementations of Quicksort are not a stable sort, meaning that the relative order of equal sort items is not preserved. develop by British computer scientist Tony Hoare in 1959 and published in 1961, it is still a normally used algorithm for sorting. Robert Sedgewick's Ph.D. thesis in 1975 is considered a milestone in the survey of Quicksort where he resolved many open problems associated to the analysis of various pivot choice schemes including Samplesort, adaptive partitioning by Van Emden as well as derivation of expected number of comparisons and swaps. Jon Bentley and Doug McIlroy integrated various improvements for purpose in programming library, including a technique to deal with equal components and a pivot scheme known as pseudomedian of nine, where a sample of nine components is divided into groups of three and then the median of the three medians from three groups is choose. In the Java core library mailing lists, he initiated a discussion claiming his new algorithm to be superior to the runtime library's sorting method, which was at that time based on the widely used and carefully tuned variant of classic Quicksort by Bentley and McIlroy.

Recursively use the above steps to the sub-array of components with smaller values and separately to the sub-array of components with greater values. The pivot choice and partitioning steps can be done in several different ways; the choice of specific implementation schemes greatly affects the algorithm's performance.

```
/*
Petar 'PetarV' Velickovic
Algorithm: Quicksort
*/
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <complex>
#define MAX_N 1000001
using namespace std;
typedef long long lld;
int n;
int niz[MAX_N];
//Quicksort algoritam za sortiranje niza
//Slozenost: O(n log n)
void qsort(int left, int right)
{
if (left < right)
{
int i = left;
int j = right;
int pivot = niz[(i+j)/2];
while (i<=j)
{
while (niz[i]<pivot) i++;
while (niz[j]>pivot) j--;
if (i<=j)
{
swap(niz[i], niz[j]);
i++;
j--;
}
}
qsort(left,j);
qsort(i,right);
}
}
int main()
{
n = 5;
niz[0] = 4;
niz[1] = 2;
niz[2] = 5;
niz[3] = 1;
niz[4] = 3;
qsort(0, n-1);
for (int i=0;i<n;i++) printf("%d ",niz[i]);
printf("\n");
return 0;
}
```