Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd prefix-matching function to trie.py #1894
Open
Conversation
data_structures/trie/trie.py
Outdated
| lst=[] | ||
| l= depth_first_search(sub_trie, '', prefix, lst) | ||
| return l | ||
| print_words(sub_trie, prefix) |
This comment has been minimized.
This comment has been minimized.
cclauss
Apr 20, 2020
Member
Algorithm functions should not print(). Please return the results to the caller.
This comment has been minimized.
This comment has been minimized.
data_structures/trie/trie.py
Outdated
| @@ -89,9 +92,7 @@ def depth_first_search(root: TrieNode, s: str, prefix: str, lst): | |||
| if sub_trie==False: | |||
| return False | |||
This comment has been minimized.
This comment has been minimized.
|
@cclauss Hey can you look at my changes once again. The code is building and passing pytests but it is still failing Travis Cl and codespell tests. Thank you. |
|
Codespell says ./data_structures/trie/trie.py:84: resturns ==> returns Travis says >>> get_words_starting_with("a") |
| @@ -55,7 +55,7 @@ def get_words_starting_with(self, prefix: str) -> [str]: | |||
| :param prefix: the prefix to be matched | |||
This comment has been minimized.
This comment has been minimized.
|
codespell errors |
|
|
||
| def depth_first_search(node: TrieNode, word: str, lst): | ||
| """ | ||
| resturns a list of all the nodes in a trie |
This comment has been minimized.
This comment has been minimized.
mrmaxguns
May 7, 2020
Contributor
Line 84 is causing codespell tests to fail. Easy typo resturns to returns
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
tasbihaasim commentedApr 19, 2020
•
edited
Added a new function match to trie.py. This function takes a prefix as an argument, traces that prefix in a trie and then iterates through all the succeeding letters in the sub-trie such that a list of words containing that prefix is returned.
Checklist:
Fixes: #{$ISSUE_NO}.