一.冒泡排序
/** * 冒泡排序 * 冒泡排序平均时间复杂度为:O(n2);空间复杂度 O(n) */ public class BubbleSort { public static void main(String[] args){ int[] intList = {1,2,4,3,5,0,8,69,70,53}; bubbleSort(intList); } //排序 static void bubbleSort(int[] intList){ int temp = 0; for(int i=0;i<intList.length;i++){ for(int j=0;j<intList.length-i-1;j++){ if (intList[j] > intList[j+1]){ temp =intList[j]; intList[j] = intList[j+1]; intList[j+1] = temp; } } } System.out.println(Arrays.toString(intList)); } }