-
Notifications
You must be signed in to change notification settings - Fork 32
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
Implement Multi-threaded Merge Sort in Java and Rust #53
base: main
Are you sure you want to change the base?
Implement Multi-threaded Merge Sort in Java and Rust #53
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have given my review for your code @KiranRajeev-KV
if (arr.length > 1) { | ||
int mid = arr.length / 2; | ||
|
||
int[] left = new int[mid]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, this could fail if there is a null array (NOT EMPTY). [ NullPointerException is bound to occur] .......
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For very large arrays, int mid = arr.length / 2; could lead to integer overflow if arr.length exceeds Integer.MAX_VALUE (unlikely but theoretically possible).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a check for null arrays
|
||
// Threshold to switch to normal merge sort | ||
// change this value according to the size of the array to get the best performance | ||
private static final int THRESHOLD = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the THRESHOLD = 5 seem to look too low ? For performance measurement with small arrays, creating threads is more expensive than sorting them sequentially.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the threshold.
PR: Implement Multi-threaded Merge Sort in Java and Rust
This PR adds the implementation of Multi-threaded Merge Sort in both Java and Rust, as stated in issue #42.
Added Features
Changes Made
.gitignore
to excludetarget
anddebug
folders from CargoREADME.md
to add instructions for Rust code execution using Cargo