-
Notifications
You must be signed in to change notification settings - Fork 497
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
Fixed median algorithm bug #484
Conversation
Hi! Thanks for showing interest in contributing to this repository. Please make sure that you have ticked the points mentioned in PR description correctly. Thanks again! |
return i | ||
elif aj == med_val: | ||
return j | ||
return k |
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.
The code does not comply to PEP8.
Origin: PEP8Bear, Section: pep8
.
The issue can be fixed by applying the following patch:
--- a/tmp/tmp4__xq2to/quick_sort/quick_sort.py
+++ b/tmp/tmp4__xq2to/quick_sort/quick_sort.py
@@ -14,6 +14,7 @@
elif aj == med_val:
return j
return k
+
def partition(array, l, r):
"""
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.
Ah yes - my apologies. My pep8 vim plugin did not catch this for some reason.... updating the PR now!
48f051e
to
b280c26
Compare
@singhpratyush I added an extra newline and updated the commit |
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.
LGTM 👍
ping @singhpratyush
Fixes #436
Modified the algorithm slightly to first find the median value, then find the index corresponding to that value. The basic idea is to sum the values, then remove the max and min values, leaving the median as the result.
By submitting this pull request I confirm I've read and complied with the below declarations.
Added {Algorithm/DS name} [{Language}]
, notUpdate README.md
orAdded new code
.