mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-27 03:50:19 +08:00
fix: Several code bug fixes (#973)
* Update counting_sort.c and quick_sort.c * Code bug fixes.
This commit is contained in:
@@ -29,7 +29,6 @@ void countingSortNaive(int nums[], int size) {
|
||||
nums[i] = num;
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 释放内存
|
||||
free(counter);
|
||||
}
|
||||
@@ -65,7 +64,6 @@ void countingSort(int nums[], int size) {
|
||||
}
|
||||
// 使用结果数组 res 覆盖原数组 nums
|
||||
memcpy(nums, res, size * sizeof(int));
|
||||
|
||||
// 5. 释放内存
|
||||
free(counter);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ int medianThree(int nums[], int left, int mid, int right) {
|
||||
return right;
|
||||
}
|
||||
|
||||
// 哨兵划分(三数取中值)
|
||||
/* 哨兵划分(三数取中值) */
|
||||
int partitionMedian(int nums[], int left, int right) {
|
||||
// 选取三个候选元素的中位数
|
||||
int med = medianThree(nums, left, (left + right) / 2, right);
|
||||
|
||||
Reference in New Issue
Block a user