Skip to main content

Trie Vis

Prefix Tree • Autocomplete

Insert a word to visualize the trie

Run Insert or Search to see explanation.

1x
Ready
Algorithm Details

Run Insert or Search to see explanation.

Complexity (m = word length)

Time

O(m)

Space

O(m)

Trie Insert
1def insert(word):
2 node = root
3 for char in word:
4 if char not in node.children:
5 node.children[char] = TrieNode()
6 node = node.children[char]
7 node.is_end = True