-
Notifications
You must be signed in to change notification settings - Fork 314
Adding QuickSort Algorithm #274
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
Codecov Report
@@ Coverage Diff @@
## master #274 +/- ##
=============================================
- Coverage 98.810% 98.617% -0.193%
=============================================
Files 23 23
Lines 2353 2387 +34
=============================================
+ Hits 2325 2354 +29
- Misses 28 33 +5
|
| quick_sort(array,start=start,end=s) | ||
| quick_sort(array,start=s+1,end=end) |
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 is recursive. Please convert it into iterative logic.
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 use the notion of stacks to do it.
|
Are you participating through GSSoC, 2020? |
Where can this code be used other than in quick sort algorithm? Serial version isn't needed, only parallel version is to be added. Do not close this PR, just update this with the parallel version of quick sort and remove the sequential version. |
|
@czgdp1807 , I tried using Stack from miscellaneous_data_structures in my implementation of iterative quick sort , however I'm getting import error when importing Stack |
|
Yes I'm participating through GSSOC as of now |
You can use python list as a stack. No problems. |
| ========== | ||
| .. [1] https://en.wikipedia.org/wiki/Quicksort | ||
| .. [2] https://www.geeksforgeeks.org/quick-sort |
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.
| .. [2] https://www.geeksforgeeks.org/quick-sort |
Please use, wikipedia/university lectures/research papers as references.
|
Sorry for the delay, couldn't work for some time. |
|
Well, a stack is a list. So you can access any element from inside it. Launch threads for some of the top elements. It's just like a tree, all the leafs are processed parallely in the bottom layer, then the second last, and so on till we reach the top. |
|
I think you forgot to add tests for your patch. See, tests folder under linear_data_structures. |
|
@anirudh-kac Are you working on it? Please do not close the PR. |
|
@czgdp1807 sorry for replying late. I was having some trouble with the parallel implementation and got busy with some college stuff later tbh. |
|
See, https://en.wikipedia.org/wiki/Quicksort#Parallelization and a lot PDFs on the web. |
|
Hi @anirudh-kac are you still working on it ! feel free to ask your queries here |
|
@robotjellyzone I had some trouble implementing the iterative parallel version of quick sort. I went through some resources over the internet but couldn't really figure out how to implement it. I'm still trying but I won't mind if anyone else takes over the issue as I've taken a lot of time |
@anirudh-kac have you checked this https://en.wikipedia.org/wiki/Quicksort#Parallelization already? if so then that's totally fine i would add |
|
Is this PR still in progress or should I take it over! |
You can take it over. |
|
Closing in favor of #314 |
Fixes #273
Brief description of what is fixed or changed
I implemented the quick sort algorithm . Added required _partition function and quick_sort function in pydatastructs.linear_data_structures.algorithms
I checked all export statements and init files to make sure it's working
Other comments
This is the non parallel version.
I'm also working on the parallel version , but I was facing some issues with that.
Since some code from this will be reused and this is working fine , I'm making a PR for this version first