Skip to content
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

Adding Quicksort #314

Merged
merged 61 commits into from
Jan 16, 2021
Merged

Adding Quicksort #314

merged 61 commits into from
Jan 16, 2021

Conversation

Arvind-raj06
Copy link
Member

@Arvind-raj06 Arvind-raj06 commented Jan 13, 2021

Quicksort

References to other Issues or PRs or Relevant literature

Fixes #273. See
#273

Brief description of what is fixed or changed

This code fixes the quick sort issue on iterative implementation as reference with the site https://www.tutorialspoint.com/python-program-for-iterative-quick-sort

Other comments

Hope this code works fine and if there is any issue ping me, yes this PR also included the SWOC participation

@codecov
Copy link

codecov bot commented Jan 13, 2021

Codecov Report

Merging #314 (bcb678e) into master (78d8254) will increase coverage by 0.011%.
The diff coverage is 100.000%.

@@              Coverage Diff              @@
##            master      #314       +/-   ##
=============================================
+ Coverage   98.874%   98.885%   +0.011%     
=============================================
  Files           25        25               
  Lines         3021      3052       +31     
=============================================
+ Hits          2987      3018       +31     
  Misses          34        34               
Impacted Files Coverage Δ
pydatastructs/linear_data_structures/__init__.py 100.000% <ø> (ø)
pydatastructs/linear_data_structures/algorithms.py 99.572% <100.000%> (+0.065%) ⬆️

Impacted file tree graph


lower = kwargs.get('start', 0)
upper = kwargs.get('end', len(array) - 1)
stack, top = [0] * (upper - lower + 1), -1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a Stack class (see below).

Try using the above as stack.

P.S. The iterative version seems nice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool I will use the stack there in the program ^ ^

Copy link

@vatsalkesarwani12 vatsalkesarwani12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Arvind-raj06
Copy link
Member Author

@czgdp1807 Yep done

@czgdp1807
Copy link
Member

There is one thing missing in the API which is the acceptance of a function which should select the pivot with respect to which partition should be done. Currently, high is the pivot but what if the user wants to select randomly?
kwargs should also accept, pick_pivot_element which should be the method provided by the user. It should be optional and by default will pick high. pick_pivot_element will be passed to partition and will always be called as, pick_pivot_element(low, high, array).

In addition to the above, please do not use Github as your editor as any commit made on Github triggers Travis CI tests leading to wastage of resources. You may follow the steps below to pull the changes to your system, running tests locally until they pass and then push here.
Assuming that you have git and pip (for python3) installed

  1. pip install pytest (You may need to use sudo to provide write access to pip)
  2. pip install pytest-cov (You may need to use sudo to provide write access to pip)
  3. git clone https://github.com/codezonediitj/pydatastructs
  4. python path/to/pydatastructs/setup.py develop (You may need to provide sudo access)
  5. git remote add origin_user https://github.com/Arvind-raj06/pydatastructs/
  6. git pull origin_user "Let'scode"
  7. Do your changes
  8. python -m pytest --doctest-modules --cov=./ --cov-report=xml -s (under pydatastructs)
  9. If tests pass, push using, git push origin_user "Let'scode". Otherwise go to 6 and keep on repeating until tests pass.

@Arvind-raj06
Copy link
Member Author

There is one thing missing in the API which is the acceptance of a function which should select the pivot with respect to which partition should be done. Currently, high is the pivot but what if the user wants to select randomly?
kwargs should also accept, pick_pivot_element which should be the method provided by the user. It should be optional and by default will pick high. pick_pivot_element will be passed to partition and will always be called as, pick_pivot_element(low, high, array).

In addition to the above, please do not use Github as your editor as any commit made on Github triggers Travis CI tests leading to wastage of resources. You may follow the steps below to pull the changes to your system, running tests locally until they pass and then push here.
Assuming that you have git and pip (for python3) installed

  1. pip install pytest (You may need to use sudo to provide write access to pip)
  2. pip install pytest-cov (You may need to use sudo to provide write access to pip)
  3. git clone https://github.com/codezonediitj/pydatastructs
  4. python path/to/pydatastructs/setup.py develop (You may need to provide sudo access)
  5. git remote add origin_user https://github.com/Arvind-raj06/pydatastructs/
  6. git pull origin_user "Let'scode"
  7. Do your changes
  8. python -m pytest --doctest-modules --cov=./ --cov-report=xml -s (under pydatastructs)
  9. If tests pass, push using, git push origin_user "Let'scode". Otherwise go to 6 and keep on repeating until tests pass.

Yes sure I had a copy but I thought using travis would be easier, ok now onwards I will do it local system

@czgdp1807 czgdp1807 added hard and removed medium labels Jan 16, 2021
@czgdp1807 czgdp1807 merged commit e639bc6 into codezonediitj:master Jan 16, 2021
@Arvind-raj06 Arvind-raj06 deleted the Let'scode branch January 23, 2021 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quick Sort
3 participants