Skip to content

Commit 52f7e4e

Browse files
author
Christian Bender
authored
Merge pull request TheAlgorithms#429 from Hero22/master
the second array may have residual elements.
2 parents 3e64771 + 4f95d81 commit 52f7e4e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Sorts/src/sort/MergeSort.java

+6
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ private static <T extends Comparable<T>> void merge(T[] arr, T[] temp, int left,
8585
i++;
8686
k++;
8787
}
88+
89+
while (j <= right) {
90+
arr[k] = temp[j];
91+
j++;
92+
k++;
93+
}
8894
}
8995

9096
// Driver program

0 commit comments

Comments
 (0)