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

Feature: Moore's voting algorithm is added #5770

Conversation

dhavalkgit
Copy link

Hi

I have implemented Moore's Voting Algorithm to find the majority element in a list or array. The code includes the following improvements and features:

First Pass: first find the majority element using Moore's voting algorithm.

Second Pass Verification: After determining a candidate using Moore's Voting Algorithm, the code performs a second pass to verify if the element truly appears more than n/2 times.

feature #5654

@codecov-commenter
Copy link

codecov-commenter commented Oct 13, 2024

Codecov Report

Attention: Patch coverage is 0% with 22 lines in your changes missing coverage. Please review.

Project coverage is 63.97%. Comparing base (596c614) to head (c5e24a2).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...atastructures/hashmap/hashing/MajorityElement.java 0.00% 22 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5770      +/-   ##
============================================
- Coverage     64.05%   63.97%   -0.09%     
- Complexity     4177     4178       +1     
============================================
  Files           584      584              
  Lines         16332    16354      +22     
  Branches       3152     3158       +6     
============================================
+ Hits          10461    10462       +1     
- Misses         5445     5467      +22     
+ Partials        426      425       -1     

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

@siriak
Copy link
Member

siriak commented Oct 14, 2024

The algorithm is the same for arrays and lists, so it's just duplication

@siriak siriak closed this Oct 14, 2024
@dhavalkgit
Copy link
Author

If you pass an array as an argument, then it converts into a list and is called an algorithm.

image image

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