-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Add a recursive merge sort algorithm that accepts an array as input. #4462
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
Conversation
Recursive Merge Sort That Accepts an Array
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.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
sorts/recursive_mergesort_array.py
Outdated
middle = len(arr) // 2 | ||
left = arr[:middle] | ||
right = arr[middle:] | ||
leftSize = len(left) |
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.
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: leftSize
sorts/recursive_mergesort_array.py
Outdated
left = arr[:middle] | ||
right = arr[middle:] | ||
leftSize = len(left) | ||
rightSize = len(right) |
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.
Variable and function names should follow the snake_case
naming convention. Please update the following name accordingly: rightSize
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.
Hello! Thanks for your contribution. This is my review of the code.
The two main things are:
- If statements are usually written as
if EXPRESSION
and notif(EXPRESSION)
- Incrementing a variable and assigning the result to it can be done with
+=
If you disagree with any review, please leave a comment. Thanks!
Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>
Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>
Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>
Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>
Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>
Please run Black on your code. Pre-commit failed because Black found issues. Install black with |
Flake8 failed because:
|
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.
A final review. Please add a docstring to the function briefly describing the mergesort method (and a link to the Wikipedia article for it). Also, please add comments describing various parts of the function (this doesn't have to be excessive, but should help the reader better understand what is happening).
A mergesort function has already been implemented, but I believe this can be merged after review, as the method of implementing the algorithm is different. Thank you for your contribution! 👍
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.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
I apologize for the wait. Pre-commit failed because of the comments. It wants the comments in the format |
Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>
Thank you for your contribution 🎆 |
…heAlgorithms#4462) This is a different recursive implementation of the merge sort algorithm. * Recursive Merge Sort That Accepts an Array Recursive Merge Sort That Accepts an Array * Add Wikipedia Link * Fixes naming conventions * Update sorts/recursive_mergesort_array.py Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com> * Update sorts/recursive_mergesort_array.py Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com> * Update sorts/recursive_mergesort_array.py Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com> * Update sorts/recursive_mergesort_array.py Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com> * Update sorts/recursive_mergesort_array.py Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com> * Adds black format * Removes unused variables * Fixes variable names and adds documentation * Fixes variable names to use snake_case. * Removes double #. * Update sorts/recursive_mergesort_array.py Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com> Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com> Co-authored-by: Benjamin Fein <benfein78@icloud.com>
…heAlgorithms#4462) This is a different recursive implementation of the merge sort algorithm. * Recursive Merge Sort That Accepts an Array Recursive Merge Sort That Accepts an Array * Add Wikipedia Link * Fixes naming conventions * Update sorts/recursive_mergesort_array.py Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com> * Update sorts/recursive_mergesort_array.py Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com> * Update sorts/recursive_mergesort_array.py Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com> * Update sorts/recursive_mergesort_array.py Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com> * Update sorts/recursive_mergesort_array.py Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com> * Adds black format * Removes unused variables * Fixes variable names and adds documentation * Fixes variable names to use snake_case. * Removes double #. * Update sorts/recursive_mergesort_array.py Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com> Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com> Co-authored-by: Benjamin Fein <benfein78@icloud.com>
Add a recursive merge sort algorithm that accepts an array as input.
Describe your change:
Add a recursive merge sort algorithm that accepts an array as input.
Checklist:
Fixes: #{$ISSUE_NO}
.