Commit 851fe8f
committed
Removed redundant parameters and cleaned up code
-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.1 parent d1ca661 commit 851fe8f
1 file changed
+14
-35
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | 28 | | |
39 | 29 | | |
40 | | - | |
41 | | - | |
| 30 | + | |
| 31 | + | |
42 | 32 | | |
43 | | - | |
44 | | - | |
| 33 | + | |
| 34 | + | |
45 | 35 | | |
46 | 36 | | |
47 | 37 | | |
| |||
59 | 49 | | |
60 | 50 | | |
61 | 51 | | |
62 | | - | |
| 52 | + | |
63 | 53 | | |
64 | | - | |
| 54 | + | |
65 | 55 | | |
66 | 56 | | |
67 | | - | |
68 | | - | |
| 57 | + | |
69 | 58 | | |
70 | 59 | | |
71 | 60 | | |
72 | 61 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
| 62 | + | |
78 | 63 | | |
79 | 64 | | |
80 | 65 | | |
81 | 66 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 67 | + | |
| 68 | + | |
86 | 69 | | |
87 | 70 | | |
88 | | - | |
89 | | - | |
90 | | - | |
| 71 | + | |
91 | 72 | | |
92 | 73 | | |
93 | 74 | | |
94 | 75 | | |
95 | | - | |
96 | | - | |
97 | | - | |
| 76 | + | |
98 | 77 | | |
99 | 78 | | |
100 | 79 | | |
| |||
0 commit comments