-
Notifications
You must be signed in to change notification settings - Fork 620
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
Added some Searching and Sorting Algorithms #413
base: master
Are you sure you want to change the base?
Conversation
def merge_sort(unsorted_list): | ||
if len(unsorted_list) <= 1: | ||
return unsorted_list | ||
# Find the middle point and devide it |
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.
this comment seems to not be indented, could you please fix it?
@@ -0,0 +1,19 @@ | |||
def selection_sort(input_list): | |||
|
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.
you do not need this extra line here
@@ -0,0 +1,26 @@ | |||
def shellSort(input_list): | |||
gap = len(input_list) // 2 |
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.
you can save len(input_list) here outside and reuse it as len(input_list)) is the same across the function right?
@@ -0,0 +1,26 @@ | |||
def shellSort(input_list): |
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.
from PEP8 this should be written in lower_case_with_underscores
, for e.g.:
shellSort
-> shell_sort
or shellsort
@@ -0,0 +1,18 @@ | |||
def insertion_sort(InputList): |
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 think this project is using the convention names in lower_case_with_underscores
so believe you have to fix the variable names here
int(((float(idxn - idx0)/( values[idxn] - values[idx0])) | ||
* ( x - values[idx0]))) | ||
|
||
# Compare the value at mid point with search value |
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.
don't you think the comment would be better inside the function?
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.
nice PR, some points:
- linting can be improved
- could add some docs strings in the functions
- the README should be updated as you are creating a new folder and this folder should be under algorithm, I believe
- the variable names used in the project and the file names follow the
lower_case_with_underscore
Description
Please include a summary of the change and which issue is fixed or what question/feature you have added.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
Checklist: