Skip to content

feat: enhance Trie data structure with added methods and tests #5538

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 14 commits into from
Oct 7, 2024

Conversation

sailok
Copy link
Contributor

@sailok sailok commented Oct 3, 2024

  • Renamed TrieImp.java to Trie.java to be more inclined with the naming convention
  • Refactored the TrieNode class from being an Inner Class to separate class with in Trie.java
  • Use HashMap instead of TrieNode array in children, to incorporate all character values instead if lowercase english alphabets.
  • Add countWords, startsWithPrefix and countWordsWithPrefix methods to enhance Trie capability.
  • Add Test Cases to all the Trie methods.
  • 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
Copy link

codecov-commenter commented Oct 3, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 6 lines in your changes missing coverage. Please review.

Project coverage is 58.12%. Comparing base (6868bf8) to head (5658fa6).

Files with missing lines Patch % Lines
...a/com/thealgorithms/datastructures/trees/Trie.java 83.33% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5538      +/-   ##
============================================
+ Coverage     58.08%   58.12%   +0.04%     
- Complexity     3669     3676       +7     
============================================
  Files           546      546              
  Lines         15776    15796      +20     
  Branches       3000     3006       +6     
============================================
+ Hits           9164     9182      +18     
  Misses         6224     6224              
- Partials        388      390       +2     

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

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

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

Please remove main and add JUnit tests

sailok and others added 3 commits October 5, 2024 09:12
- Rename TrieImp Class to Trie
- Add countWords, startsWithPrefix, countWordsWithPrefix methods
- Add test cases
@sailok sailok changed the title feat: extend Trie implementation from lowercase english alphabets to all ascii characters feat: enhance Trie data structure with added methods and tests Oct 5, 2024
@sailok sailok requested a review from siriak October 5, 2024 04:18
@sailok sailok closed this Oct 5, 2024
@sailok sailok reopened this Oct 5, 2024
Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@siriak siriak enabled auto-merge (squash) October 7, 2024 21:08
@siriak siriak merged commit 5dcf6c0 into TheAlgorithms:master Oct 7, 2024
6 checks passed
@sailok sailok deleted the trie-imp branch October 8, 2024 05:02
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