This function partitions a [ ] in three parts a ) a [ l . . i ] contains all elements smaller than pivot b ) a [ i + 1. . j - 1 ] contains all occurrences of pivot c ) a [ j . . r ] contains all elements greater than pivot
void partition ( int a [ ] , int l , int r , int & i , int & j ) { i = l - 1 , j = r ; int p = l - 1 , q = r ; int v = a [ r ] ; while ( true ) {