Skip to content

Instantly share code, notes, and snippets.

@VictorSouzas
Created November 13, 2017 15:55
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 VictorSouzas/2c64f22aa255b8d5f1f32087956feb8b to your computer and use it in GitHub Desktop.
Save VictorSouzas/2c64f22aa255b8d5f1f32087956feb8b to your computer and use it in GitHub Desktop.
private int partition(int min, int max) {
int pivot = this.vector[max];
int wall = min-1;
for (int i = min; i <= max-1; i++){
if(this.vector[i] <= pivot){
wall++;
swap(wall,i);
}
}
swap(wall + 1, max);
return wall+1;
}
private void swap(int wall, int i) {
int aux = this.vector[wall];
this.vector[wall] = this.vector[i];
this.vector[i] = aux;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment