Skip to content

the second array may have residual elements. #429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 18, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
the second array may have residual elements.
  • Loading branch information
wzx committed Apr 26, 2018
commit 172998b1ba0fcefd7f2bd56fd5cd4583da458d8d
6 changes: 6 additions & 0 deletions Sorts/src/sort/MergeSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ private static <T extends Comparable<T>> void merge(T[] arr, T[] temp, int left,
i++;
k++;
}

while (j <= right) {
arr[k] = temp[j];
j++;
k++;
}
}

// Driver program
Expand Down