Skip to content

Fix CountingSort for negative numbers #100

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

Merged
merged 1 commit into from
Jul 22, 2018

Conversation

dubzzz
Copy link
Contributor

@dubzzz dubzzz commented Jul 20, 2018

When trying to run property based tests on the sorting algorithms available in javascript-algorithms, I detected sorting issues on CountingSort and RadixSort with arrays having negative entries.

Here is a fix to be able to handle negative integers in CountingSort.

The commit adding property based tests to the sorting algorithms is available at dubzzz@34b0c46
If you are interested in such testing approach I can issue another pull request to add those tests too.

@dubzzz dubzzz force-pushed the fix-countingsort branch from 522f949 to a1dcc4b Compare July 20, 2018 23:13
@dubzzz dubzzz force-pushed the fix-countingsort branch from a1dcc4b to 2a3e7da Compare July 20, 2018 23:15
@codecov-io
Copy link

Codecov Report

Merging #100 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #100   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files         115    115           
  Lines        2252   2255    +3     
  Branches      390    391    +1     
=====================================
+ Hits         2252   2255    +3
Impacted Files Coverage Δ
...c/algorithms/sorting/counting-sort/CountingSort.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc89336...2a3e7da. Read the comment docs.

@trekhleb trekhleb changed the base branch from master to counting-sorting-fix July 22, 2018 15:01
@trekhleb
Copy link
Owner

Thank you for your PR @dubzzz

@trekhleb trekhleb merged commit 3be02b5 into trekhleb:counting-sorting-fix Jul 22, 2018
shoredata pushed a commit to shoredata/javascript-algorithms that referenced this pull request Mar 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants