MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / autocomplete_using_trie

Function autocomplete_using_trie

strings/autocomplete_using_trie.py:41–54  ·  view source on GitHub ↗

>>> trie = Trie() >>> for word in words: ... trie.insert_word(word) ... >>> matches = autocomplete_using_trie("de") >>> "detergent " in matches True >>> "dog " in matches False

(string: str)

Source from the content-addressed store, hash-verified

39
40
41def autocomplete_using_trie(string: str) -> tuple:
42 """
43 >>> trie = Trie()
44 >>> for word in words:
45 ... trie.insert_word(word)
46 ...
47 >>> matches = autocomplete_using_trie("de")
48 >>> "detergent " in matches
49 True
50 >>> "dog " in matches
51 False
52 """
53 suffixes = trie.find_word(string)
54 return tuple(string + word for word in suffixes)
55
56
57def main() -> None:

Callers 1

mainFunction · 0.85

Calls 1

find_wordMethod · 0.80

Tested by

no test coverage detected