Skip to content

Conversation

Zubayear
Copy link

This PR improves the Trie implementation:

  • Improve time complexity of Size() - O(1)
  • Remove unnecessary update of isLeaf flag on duplicate node
  • Empty string insertion prevented
  • Lazy remove decrements total count correctly
  • Added edge-case tests:
    • Empty string insertion
    • Substrings and shared prefixes
    • Removing non-existent words
    • Removing words sequentially
  • Added benchmark for Size()

This makes the Trie faster, safer, and properly tested.

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.

1 participant