Prints all the words in a Trie :param node: root node of Trie :param word: Word variable should be empty at start :return: None
(node: TrieNode, word: str)
| 49 | |
| 50 | |
| 51 | def print_words(node: TrieNode, word: str): # noqa: E999 This syntax is Python 3 only |
| 52 | """ |
| 53 | Prints all the words in a Trie |
| 54 | :param node: root node of Trie |
| 55 | :param word: Word variable should be empty at start |
| 56 | :return: None |
| 57 | """ |
| 58 | if node.is_leaf: |
| 59 | print(word, end=' ') |
| 60 | |
| 61 | for key, value in node.nodes.items(): |
| 62 | print_words(value, word + key) |
| 63 | |
| 64 | |
| 65 | def test(): |
nothing calls this directly
no outgoing calls
no test coverage detected