strings.autocomplete_using_trie

Attributes

END

trie

words

Classes

Trie

Functions

autocomplete_using_trie(→ tuple)

main(→ None)

Module Contents

class strings.autocomplete_using_trie.Trie
_elements(d: dict) tuple
find_word(prefix: str) tuple | list
insert_word(text: str) None
_trie: dict
strings.autocomplete_using_trie.autocomplete_using_trie(string: str) tuple
>>> trie = Trie()
>>> for word in words:
...     trie.insert_word(word)
...
>>> matches = autocomplete_using_trie("de")
>>> "detergent " in matches
True
>>> "dog " in matches
False
strings.autocomplete_using_trie.main() None
strings.autocomplete_using_trie.END = '#'
strings.autocomplete_using_trie.trie
strings.autocomplete_using_trie.words = ('depart', 'detergent', 'daring', 'dog', 'deer', 'deal')