Optimization for shell sort#4038
Optimization for shell sort#4038l3str4nge merged 3 commits intoTheAlgorithms:masterfrom realDuYuanChao:ShellSort
Conversation
|
I do not quite understand the title of this PR. In what way is the current implementation broken? |
We should insert value instead of swapping elements of array. |
|
Is your implementation improve performance or what? If so please write proper tests for proof that your solution is better than already exists. |
l3str4nge
left a comment
There was a problem hiding this comment.
Need additional tests for performance
|
Maybe we can strictly follow this?: https://en.wikipedia.org/wiki/Shellsort#Pseudocode |
poyea
left a comment
There was a problem hiding this comment.
We may add a reference to the wiki page as well.
|
@poyea Done. Please review again. |
| """ | ||
| This is a pure Python implementation of the shell sort algorithm | ||
|
|
||
| For doctests run following command: | ||
| python -m doctest -v shell_sort.py | ||
| or | ||
| python3 -m doctest -v shell_sort.py | ||
|
|
||
| For manual testing run: | ||
| python shell_sort.py | ||
| https://en.wikipedia.org/wiki/Shellsort#Pseudocode |
There was a problem hiding this comment.
I would leave the first line like this
| """ | |
| This is a pure Python implementation of the shell sort algorithm | |
| For doctests run following command: | |
| python -m doctest -v shell_sort.py | |
| or | |
| python3 -m doctest -v shell_sort.py | |
| For manual testing run: | |
| python shell_sort.py | |
| https://en.wikipedia.org/wiki/Shellsort#Pseudocode | |
| """ | |
| This is a Python implementation of the shell sort algorithm. | |
| Reference: https://en.wikipedia.org/wiki/Shellsort#Pseudocode |
poyea
left a comment
There was a problem hiding this comment.
I would approve this as the original version has really no reference to the algorithm (or at least, the implementation didn't strictly follow the algorithm). Thank you for your pull request!🤩
Co-authored-by: John Law <johnlaw.po@gmail.com>
|
@poyea Done |
|
@mateuszz0000 Can you review again. Thanks :) |
* fixed shell sort * udpate code style * Update sorts/shell_sort.py Co-authored-by: John Law <johnlaw.po@gmail.com> Co-authored-by: John Law <johnlaw.po@gmail.com>
* fixed shell sort * udpate code style * Update sorts/shell_sort.py Co-authored-by: John Law <johnlaw.po@gmail.com> Co-authored-by: John Law <johnlaw.po@gmail.com>
* fixed shell sort * udpate code style * Update sorts/shell_sort.py Co-authored-by: John Law <johnlaw.po@gmail.com> Co-authored-by: John Law <johnlaw.po@gmail.com>
* fixed shell sort * udpate code style * Update sorts/shell_sort.py Co-authored-by: John Law <johnlaw.po@gmail.com> Co-authored-by: John Law <johnlaw.po@gmail.com>
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}.