阅读背景:

经典排序算法-java

来源:互联网 

冒泡排序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



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: