Skip to content

Instantly share code, notes, and snippets.

@bobbydeveaux
Created March 14, 2014 11:43
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 bobbydeveaux/9546209 to your computer and use it in GitHub Desktop.
Save bobbydeveaux/9546209 to your computer and use it in GitHub Desktop.
Java Bubble Sort
public class Bubble
{
public static void main(String[] args)
{
for (int c = 0; c < 1000000; c++) {
bubbleSort();
}
}
public static void bubbleSort()
{
int[] list = {3,4,1,3,5,1,92,2,4124,424,52,12};
int n = 12;
int t;
for (int c = 0; c < (n - 1); c++) {
for (int d = 0; d < n - c - 1; d++) {
if (list[d] > list[d+1]) {
t = list[d];
list[d] = list[d+1];
list[d+1] = t;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment