Picks a random pivot element between l and r and partitions arr [ l . . r ] around the randomly picked element using partition ( )
static int randomPartition ( int [ ] arr , int l , int r ) { int n = r - l + 1 ; int pivot = ( int ) ( new Random ( ) . Next ( ) % n ) ; arr = swap ( arr , l + pivot , r ) ; return Partition ( arr , l , r ) ; }