Skip to content

Instantly share code, notes, and snippets.

@YassineBajdou
Created January 11, 2019 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YassineBajdou/f9ff30e644f3b89fb84af2f447a4d883 to your computer and use it in GitHub Desktop.
Save YassineBajdou/f9ff30e644f3b89fb84af2f447a4d883 to your computer and use it in GitHub Desktop.
Quick Sort
int rand_partition ( int A[ ] , int start , int end ) {
//chooses position of pivot randomly by using rand() function .
int random = start + rand( )%(end-start +1 ) ;
swap ( A[random] , A[start]) ; //swap pivot with 1st element.
return partition(A,start ,end) ; //call the above partition function
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment