Created
March 27, 2014 01:45
-
-
Save Deathnerd/9798240 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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