冒泡排序BubbleSort
时间复杂度:O(n^2)
稳定性:稳定
public class BubbleSort {
public BubbleSort(int[] a) {
// TODO Auto-generated constructor stub
int s = 0;
for(int i = 0; i < a.length - 1; i++) {
for(int j = 0; j < a.length - 1; j++) {
if(a[j + 1] < a[j]) {
s = a[j + 1]; a[j + 1] = a[j]; a[j] = s;
}
}
}
}
}
p