Picks a random pivot element between l and r and partitions arr [ l . . r ] around the randomly picked element using partition ( )
def randomPartition ( arr , l , r ) : NEW_LINE INDENT n = r - l + 1 ; NEW_LINE pivot = random . randrange ( 1 , 100 ) % n ; NEW_LINE arr [ l + pivot ] , arr [ r ] = arr [ r ] , arr [ l + pivot ] ; NEW_LINE return Partition ( arr , l , r ) ; NEW_LINE DEDENT