快速排序【伪代码】
| 1 | // 快速排序【伪代码】 |
| 2 | void QuickSort(ElemType A[] , int low , int high){ |
| 3 | // low > high 表角标越界,low=high 子表只有一个元素,不需要进行快排,已经有序 |
| 4 | if(low<high){ |
| 5 | |
| 6 | // 获取pivot基准,将当前待排序表分成左右两个子表 |
| 7 | int pivotKey = Partition(A,low,high) |
| 8 | |
| 9 | // 对左边序列进行快排 |
| 10 | QuickSort(A,low,pivotKey-1) |
| 11 | |
| 12 | // 对右边序列进行快排 |
| 13 | QuickSort(A,pivotKey+1,high) |
| 14 | |
| 15 | } |
| 16 | return A |
| 17 | } |
| 18 | |
| 19 | int Partition(ElemType A ,int low , int high){ |
| 20 |
nothing calls this directly
no test coverage detected