Created
January 31, 2017 22:13
-
-
Save tmosest/6062e065ad24262867bdcf77d3f26ea1 to your computer and use it in GitHub Desktop.
Bubble Sort in Java
This file contains 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
// Worste case is n^2 best case is n; | |
public static void BubbleSort(int[] array) | |
{ | |
int j; | |
boolean flag = true; | |
int temp; | |
while(flag) { | |
flag = false; | |
for(j = 0; j < num.lenght - 1; j++) { | |
temp = num[j]; | |
num[j] = num[j + 1]; | |
num[j + 1] = temp; | |
flag = true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment