Skip to content

Instantly share code, notes, and snippets.

@Deathnerd
Created March 27, 2014 01:45
Show Gist options
  • Save Deathnerd/9798240 to your computer and use it in GitHub Desktop.
Save Deathnerd/9798240 to your computer and use it in GitHub Desktop.
void bubbleSort(){
bubbleSort(n-1, n-1);
}
void bubbleSort(int y, int x){
if(x==0 && y==0)
return;
for(int i=0; i <= n-1; i++){ //loop through the rows
for(int j=0; j<=n-1; j++){ //loop through the columns
if(i==y && j==x){ //if reached the end point
if(x==0) { //reached the beginning of the row
bubbleSort(y-1, n-1); //go to next row, last column
} else { //still have room on the current row
bubbleSort(y, x-1); //move down a column, but stay on the same row
}
}
//do bubble sort on 2-d array. I'm too lazy to do that
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment