Created
September 2, 2019 19:23
-
-
Save Unkn0wnCat/f1e0a1a07b5e10b2ceb6f5a4318aa318 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
class bubbleSort { | |
public static void bubbleSort(int array[]) { | |
int n = array.length; | |
for (int i = 0; i < n-1; i++) | |
for (int j = 0; j < n-i-1; j++) | |
if (array[j] > array[j+1]) | |
{ | |
int swap = array[j]; | |
array[j] = array[j+1]; | |
array[j+1] = swap; | |
} | |
} | |
public static void main(String[] args) { | |
int arr[] = {64, 34, 25, 12, 22, 11, 90}; | |
bubbleSort(arr); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment