MCPcopy Create free account
hub / github.com/142vip/408CSFamily / QuickSort

Function QuickSort

code/ds/QuickSort.cpp:2–17  ·  view source on GitHub ↗

快速排序【伪代码】

Source from the content-addressed store, hash-verified

1// 快速排序【伪代码】
2void 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
19int Partition(ElemType A ,int low , int high){
20

Callers

nothing calls this directly

Calls 1

PartitionFunction · 0.50

Tested by

no test coverage detected