Skip to content

refactor: cleanup CountingSort - #5275

Closed
alxkm wants to merge 15 commits into
TheAlgorithms:masterfrom
alxkm:refactor/counting_sort
Closed

alxkm wants to merge 15 commits into
TheAlgorithms:masterfrom
alxkm:refactor/counting_sort

Conversation

@alxkm

@alxkm alxkm commented Jul 3, 2024 •

Copy link
Copy Markdown
Member

Cleanup CountingSort
Adding test for it

Extracted method CountingSort using stream into separate class also added test for it

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

@codecov-commenter

codecov-commenter commented Jul 3, 2024 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 40.52%. Comparing base (f83bb65) to head (4d7e8b5).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5275      +/-   ##
============================================
+ Coverage     40.34%   40.52%   +0.18%     
- Complexity     2486     2500      +14     
============================================
  Files           519      521       +2     
  Lines         15479    15483       +4     
  Branches       2950     2954       +4     
============================================
+ Hits           6245     6275      +30     
+ Misses         8944     8916      -28     
- Partials        290      292       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment thread src/main/java/com/thealgorithms/sorts/CountingSort.java Outdated
Comment thread src/main/java/com/thealgorithms/sorts/CountingSort.java Outdated
@alxkm
alxkm requested a review from vil02 July 5, 2024 18:45
Comment thread src/main/java/com/thealgorithms/sorts/CountingSort.java Outdated
Comment thread src/main/java/com/thealgorithms/sorts/CountingSort.java Outdated
Comment thread src/main/java/com/thealgorithms/sorts/CountingSort.java Outdated
Comment thread src/main/java/com/thealgorithms/sorts/CountingSort.java Outdated
Comment thread src/main/java/com/thealgorithms/sorts/CountingSort.java Outdated
Comment thread src/main/java/com/thealgorithms/sorts/CountingSort.java Outdated
@alxkm
alxkm requested a review from vil02 July 5, 2024 20:47
@alxkm

alxkm commented Jul 9, 2024

Copy link
Copy Markdown
Member Author

Hello @vil02 . Could you please advise on how to handle the Pseudo Counting Sort classes? To preserve the integrity and original purpose of this repository, it might be best to remove them since they do not actually implement Counting Sort. However, they have been part of the repository for some time, and I'm unsure of the best course of action.

@vil02

vil02 commented Jul 11, 2024 •

Copy link
Copy Markdown
Member

@alxkm: I would suggest to remove them. I would guess, the original implementation was merged by accident. Introducing some QuasiPseudoAlmostCountingSort does not make much sense: it does not have any special properties.

Therefore I suggest to:

  • remove these classes (with this PR, or close this one and open a new one; from documentation point of view the second option is better),
  • implement a proper CountingSort (i.e. only nonnegative integers as an input) in a new PR.

In any case: thanks to you we have spotted a quite serious bug!

@alxkm

alxkm commented Jul 11, 2024

Copy link
Copy Markdown
Member Author

@alxkm: I would suggest to remove them. I would guess, the original implementation was merged by accident. Introducing some QuasiPseudoAlmostCountingSort does not make much sense: it does not have any special properties.

Therefore I suggest to:

  • remove these classes (with this PR, or close this one and open a new one; from documentation point of view the second option is better),
  • implement a proper CountingSort (i.e. only nonnegative integers as an input) in a new PR.

In any case: thanks to you we have spotted a quite serious bug!

Ok, thank you. Got it. This is really proper way to resolve this issue

@alxkm

alxkm commented Jul 11, 2024

Copy link
Copy Markdown
Member Author

This implementation of CountingSort is wrong. Because it works only using TreeMap, which causes wrong asymptotic for CountingSort.

This issue will be resolved in such way:

  • Removing existed Counting sort in separate PR
  • Add correct implementation for Counting Sort (this is already exist in this pull request)

All these discussed in this PR

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