How to use the Trie Visualizer
- 1. Add wordsType words separated by commas and press Build trie. Only letters a–z are used.
- 2. Choose an operationSearch for a word, list words with a prefix, insert or delete.
- 3. ReplayStep through the path character by character; matching nodes are highlighted.
Worked example
The sample words cat, car, cart, care, dog, do and dot make a trie of 11 nodes including the root: c-a branches to r and t, r continues to t and e, and d-o branches to g and t. A prefix search for "ca" follows c then a and lists 4 words: car, care, cart, cat. Searching for "ca" as a whole word says it's only a prefix, because the a node isn't marked as the end of a word. Searching "do" finds it, because "do" was inserted and its o node is marked.
Why tries are fast
Every operation walks one node per character, so it costs O(L) for a word of length L, whether the trie holds 10 words or 10 million. Shared prefixes share nodes, which saves space when words overlap a lot. That makes tries the standard structure for autocomplete, spell checkers and word games, and for interview problems like Implement Trie and Word Search II.
Deleting correctly
Deleting a word unmarks its last node, then removes nodes from the bottom up only if no other word needs them. Delete "cart" from the sample and only its t node goes; "car" and "care" stay. Delete "do" and no nodes are removed, because "dog" and "dot" still pass through them.
Frequently asked questions
Can I use capital letters or numbers?
Words are converted to lower case and anything other than a–z is removed.
Is there a limit?
No hard limit, but around 30 words keeps the drawing readable.
What does the ● mean?
That node is the end of a stored word.
Is the trie visualizer free?
Yes. Everything in the trie visualizer works without signing up. The first time you ask for a result, we ask once for your name and WhatsApp number; after that the trie visualizer and every other Uncodemy tool open straight away.