-
冒泡排序
平 均 时 间 复 杂 度 O ( n 2 ) 平均时间复杂度O(n^2) 平均时间复杂度O(n2)public static int[] BubbleSort(int[] Array){ for(int i = 1;i<Array.Length-1;i++){ for(int j = 0;j<Array.Length-i-1;j++){ if(Array[j]>Array[j+1]){ int temple = Array[j]; Array[j] = Array[j+1]; Array[j+1] = temple; } } } return Array; }
-
快速排序
平 均 时 间 复 杂 度 O ( n l o g ₂ n ) 平均时间复杂度O(nlog₂n) 平均时间复杂度O(nlog₂n)public static int[] QuickSort(int[] Array,int left,int right){ if(left < right){ int MiddleValue = Array[(left+right)/2]; int i = left - 1; int j = right + 1; while(true){ while(Array[++i] < MiddleValue && i < right); while(Array[--j] > MiddleValue && j > left); if(i >= j){ break; } else{ int temple = Array[i]; Array[i] = Array[j]; Array[j] = temple; } } QuickSort(Array,left,i-1); QuickSort(Array,j+1,right); } return Array; }
-
选择排序
八大排序C#
![](https://img-home.csdnimg.cn/images/20240711042549.png)