MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / print_words

Function print_words

data_structures/trie/trie.py:78–89  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

76
77
78def print_words(node: TrieNode, word: str) -> None:
79 """
80 Prints all the words in a Trie
81 :param node: root node of Trie
82 :param word: Word variable should be empty at start
83 :return: None
84 """
85 if node.is_leaf:
86 print(word, end=" ")
87
88 for key, value in node.nodes.items():
89 print_words(value, word + key)
90
91
92def test_trie() -> bool:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected