Last active
September 29, 2015 12:11
-
-
Save hacksoldier/c122bda1e97facf3ac2c to your computer and use it in GitHub Desktop.
BubbleSort
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
| /** | |
| * Bubble Sort with Generics | |
| */ | |
| public void bubbleSort () throws EmptyArrayException { | |
| for(int i=0; i < this.arraySort.length; i++) | |
| for (int j=0; j < this.arraySort.length - 1; j++) | |
| if(this.arraySort[j].compareTo(this.arraySort[j+1]) > 0) { | |
| T key = this.arraySort[j]; | |
| this.arraySort[j] = this.arraySort[j+1]; | |
| this.arraySort[j+1] = key; | |
| } | |
| this.printArray(); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment