AlgoViz

Trie (prefix tree)

medium 20 min

A trie (pronounced "try") is a tree that stores strings one character per level, so words with the same opening letters share the same path from the root.

A complete trie: insert, search, starts_with, delete, autocomplete

Read it, run it, change a line and run it again.

Loading editor…

Children live in a dict, so any character works. Every operation is O(L) in the string length; autocomplete adds the size of the answers.