A Trie/Prefix Tree is a kind of search tree used to provide quick lookup of words/patterns in a set of words. A basic Trie however has O(n^2) space complexity making it impractical in practice. It however provides O(max(search_string, length of longest word)) lookup time making it an optimal approach when space is not an issue.
|
|
|
|
|
Prints all the words in a Trie |
|
|
|
Deletes a word in a Trie :param word: word to delete :return: None
Tries to find word in a Trie :param word: word to look for :return: Returns True if word is found, False otherwise
Inserts a word into the Trie :param word: word to be inserted :return: None
Inserts a list of words into the Trie :param words: list of string words :return: None
>>> pytests()
Prints all the words in a Trie :param node: root node of Trie :param word: Word variable should be empty at start :return: None