Bubble Sort 冒泡排序

//Bubble Sort ( O(n²))
public class TestBubbleSort { public int[] bubbleSortArray(int[] arr){
for(int i = ; i < arr.length; i ++){
for(int j = ; j < arr.length -i ; j ++){
if(arr[j]>arr[j+]){
int temp;
temp = arr[j];
arr[j] = arr[j+];
arr[j+] = temp;
}
}
}
return arr;
} public static void main(String[] args) {
int[] arr = {,,,,,};
TestBubbleSort test = new TestBubbleSort();
arr = test.bubbleSortArray(arr); for(int i = ; i < arr.length; i ++){
System.out.println(arr[i]);
}
} }

冒泡(Bubble)排序——相邻交换 时间复杂度:( O(n²))

上一篇:codeforces 741D Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths


下一篇:vue todolist 1.0