fix: Several code bug fixes (#973)

* Update counting_sort.c and quick_sort.c

* Code bug fixes.
This commit is contained in:
Yudong Jin
2023-11-29 23:14:55 +08:00
committed by GitHub
parent 56b20eff36
commit b824d149cb
4 changed files with 4 additions and 6 deletions

View File

@@ -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);
}

View File

@@ -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);