-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
Trie implementation #111
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
Trie implementation #111
Conversation
* Basic definition of Trie in comments at the top of the file * Defined Trie class and method signatures.
* Finished function to insert a word into Trie * Finished function to find a word in the Trie * Added Test functions with Assertions
data_structures/Trie/Trie.py
Outdated
making it impractical in practice. It however provides O(max(search_string, length of longest word)) lookup | ||
time making it an optimal approach when space is not an issue. | ||
|
||
This implementation assumes the character $ is not in any of the words. This character is used in the implementation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please find some way to achieve the desired result without setting a predefined character? An algorithm is supposed to consider all test cases in mind. Good job though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, no prob! I'll work on it
data_structures/Trie/Trie.py
Outdated
def test(): | ||
words = [] | ||
# Load words from text file into Trie | ||
with open("../../other/Dictionary.txt", "r") as ins: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please switch this with a string sample? This would make it easier for the user to run and test the code. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the sample I had in 9a52167 ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taking input from a file makes it difficult to test the algorithm. Please get input from user or else, add a sample input.
* No longer reading from file but instead provided simple sample input for easier testing
@sachinarora707 @r0hit-gupta I'm now using a boolean attribute instead of the $ and provided a list of strings instead of reading from the file |
@JavonDavis great job. Please delete the empty |
Regarding #105 I've worked on a Trie implementation using a dict