Returns the correct position of pivot element
int Partition ( int arr [ ] , int l , int r ) { int lst = arr [ r ] , i = l , j = l ; while ( j < r ) { if ( arr [ j ] < lst ) { swap ( & arr [ i ] , & arr [ j ] ) ; i ++ ; } j ++ ; } swap ( & arr [ i ] , & arr [ r ] ) ; return i ; }