aalhour / aalhour/C-Sharp-Algorithms
Inefficient merge soft
- 主要语言
- C#
- 星标
- 6.2k
- 派生
- 1.4k
- PR 合并指标
- 30 天内没有已合并 PR
描述
```
int midIndex = collection.Count / 2;
var leftCollection = collection.GetRange(startIndex, midIndex);
var rightCollection = collection.GetRange(midIndex, (endIndex - midIndex) + 1);
leftCollection = InternalMergeSort(leftCollection, 0, leftCollection.Count - 1, comparer);
rightCollection = InternalMergeSort(rightCollection, 0, rightCollection.Count - 1, comparer);
```
No need to invoke GetRange, as it copies the data and consumes extra memory. Passing StartIndex, EndIndex along with the original array should be sufficient. Don't you think so?
贡献指南
调研方向
查看项目中的归并排序实现,它可能位于与排序相关的文件中。该 issue 指出了通过 GetRange 进行不必要复制的问题。检查递归调用 InternalMergeSort 的方式,并修改它,使其使用原始集合上的起始和结束索引。通过运行现有的排序测试来验证更改。
由索引模型根据 Issue 内容生成。
评估
- Issue 类型
- 重构
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 65/100