aalhour / aalhour/C-Sharp-Algorithms

Inefficient merge soft

未关闭 适合新手
#44 3 条评论 0 个 reaction 已指派 1 人 已被 @davidich 认领 在 GitHub 查看
optimization
主要语言
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

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。