資料結構›Ch7 搜尋與排序
第 60 題/共 76 題
◀ DS 60/76
60. Quick Sort、Partition、C 程式
#DS-07-060易Quick SortPartitionC 程式

[1%, 1%, 1%, 1%] The following C program implements Quick sort. Please fill the four missing parts of the program.

int Partition(int *arr, int front, int end){
    int pivot = arr[end];
    int i = front - 1;
    for (int j = front; j < end; j++) {
        if (arr[j] < pivot) {
            ____(A)____;
            swap(&arr[i], &arr[j]);
        }
    }
    i++;
    swap(&arr[i], &arr[end]);
    ____(B)____;
}

void QuickSort(int *arr, int front, int end){
    if (front < end) {
        int pivot = Partition(arr, front, end);
        QuickSort(____C____);
        QuickSort(____D____);
    }
}
📄 成大111
跳轉到第題
▤完整推導請見《WH 資工筆記 · 資料結構》Ch7 搜尋與排序
本章題號 · 41–60 / 76