Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implement Trie Data Structure
This pull request introduces a new Trie data structure implementation to the marcosfede/algorithms repository. The Trie, also known as a prefix tree, is an efficient tree-like data structure used for storing and retrieving strings, making it particularly useful for tasks such as autocomplete, spell checking, and IP routing.
Features
insert(word)
: Inserts a word into the trie.search(word)
: Searches for a complete word in the trie.starts_with(prefix)
: Checks if any word in the trie starts with the given prefix.Implementation Details
TrieNode
andTrie
.TrieNode
represents each node in the Trie, containing:Test Cases
A comprehensive test suite has been created to verify the functionality of the Trie implementation. The test cases cover:
Files Added
/tree/trie/new_trie.py
: Contains the Trie implementation./tree/trie/test_new_trie.py
: Contains the test cases for the Trie.Potential Applications
This Trie implementation can be used in various applications, including:
Next Steps
This implementation aims to provide a solid foundation for Trie-based algorithms and can be easily extended or modified for specific use cases.
Additional Information
This Devin run was requested by Federico.