aalhour / aalhour/C-Sharp-Algorithms
Inefficient merge soft
- Dominant language
- C#
- Stars
- 6.2k
- Forks
- 1.4k
- PR merge metrics
- No merged PRs in 30d
Description
```
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?
Contributor guide
Research direction
Look at the merge sort implementation in the project, likely in a sorting-related file. The issue points out unnecessary copying via GetRange. Examine how the recursive InternalMergeSort is called and modify it to work with start and end indices on the original collection. Verify the change by running any existing sorting tests.
Written by the indexing model from the issue text.
Assessment
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100