Created
August 8, 2020 00:34
-
-
Save goyuninfo/1542d3e8bc50f69a788d2c77c7dea278 to your computer and use it in GitHub Desktop.
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
static void bubbleSort(int[] lst) { | |
int n = lst.length; | |
boolean swapped; | |
do | |
{ | |
swapped = false; | |
for (int i = 0; i < n-1; i++) { | |
if (lst[i] > lst[i+1]) { | |
int temp = lst[i]; | |
lst[i] = lst[i+1]; | |
lst[i+1] = temp; | |
swapped = true; | |
} | |
} | |
} while (swapped == true) | |
System.out.println(Arrays.toString(lst)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment