Skip to content

Instantly share code, notes, and snippets.

@Unkn0wnCat
Created September 2, 2019 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Unkn0wnCat/f1e0a1a07b5e10b2ceb6f5a4318aa318 to your computer and use it in GitHub Desktop.
Save Unkn0wnCat/f1e0a1a07b5e10b2ceb6f5a4318aa318 to your computer and use it in GitHub Desktop.
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