Skip to content

Instantly share code, notes, and snippets.

@kntmr
Created September 4, 2019 03:54
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 kntmr/7700987421eb29bb5e1317c180b99f1a to your computer and use it in GitHub Desktop.
Save kntmr/7700987421eb29bb5e1317c180b99f1a to your computer and use it in GitHub Desktop.
Bubble sort algorithm
package com.example.demo;
public class BubbleSort {
void bubbleSort(int[] a) {
for (int i = 0; i < a.length; i++) {
for (int j = i + 1; j < a.length; j++) {
if (a[i] > a[j]) {
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment