You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-The "base case" where the count of `collection` is 2 will already be handled properly if we let the collection be split and merged. There's no need to explicitly write a case for it.
-The parameters `startIndex` and `endIndex` are unneeded. `startIndex` will *always* be 0 and `endIndex` will *always* be `collection.Count - 1`. It seems someone started to write an in-place index-based MergeSort, but switched to one that splits and creates new Lists.
-Cleaned up the for loop in Merge with the strange break in the else of the if. Updated the loop condition so that we don't even have to worry about that.
-At most one of the two split Lists will still have items after the initial loop in Merge (after all, we only stop looping after we've exhausted one List, so that List can't have any more items). As such, there's no need for separate right and left index variables. Cleaned up the ending loops with this in mind.
0 commit comments