KickSolve • Free • Private

Trie Visualizer

A tree used to store strings and efficiently search prefixes, such as dictionary words. Insert words, search, delete, and list every word for a prefix, with each character step explained.

Shared prefixes visiblePrefix autocompleteEnd-of-word markers

How to use the Trie Visualizer on KickSolve

Three quick steps, no account needed.

Insert a wordEach character follows or creates a child node. Existing nodes are reused, which is how words share prefixes.
Search or list by prefixSearch checks the end-of-word ring. Prefix collects every word below a node, like autocomplete.
Delete a wordThe end mark is removed, then nodes that no other word needs are pruned from the bottom up.

About the Trie Visualizer on KickSolve

What it is and how it works.

What is a trie?

A trie, or prefix tree, stores strings character by character. Each node is one character and the path from the root spells a prefix. A marker shows which nodes end a complete word.

Key properties

  • Insert, search and delete take O(L) for a word of length L, independent of how many words are stored
  • Words with a common prefix share the same nodes
  • A prefix query finds all matching words from one subtree
  • Words come out in alphabetical order by walking children in order

Real-world uses

  • Autocomplete and search suggestions
  • Spell checkers and dictionaries
  • IP routing tables (binary tries)
  • Phone keypad predictive text

Comparing trees? Try the AVL Tree, Red-Black Tree, B-Tree or B+ Tree visualizer.

Trie cases at a glance

The situations the step-by-step log will name for you.

OperationWhat happensTime
InsertFollow or create one node per character, then mark the end of the wordO(L)
Search wordFollow every character, then check the end-of-word markerO(L)
Prefix searchFollow the prefix, then collect all words in the subtreeO(L + k)
DeleteUnmark the end, then remove nodes that have no children and end no other wordO(L)

Worked example

The same steps the visualizer animates for any input.

Insert "cat": creates c, a, t. The t node is marked as a word end.
Insert "car": reuses c and a, creates r. Marked as a word end.
Insert "dog": creates d, o, g.
9 characters stored in 7 nodes, because "ca" is shared.
Prefix "ca": cat, car (the subtree under a).

Trie FAQ

Quick answers.

What is a trie?

A tree for storing strings where each node is a character and each path from the root is a prefix. Also called a prefix tree.

What does the green double ring mean?

It marks a node where a complete stored word ends.

Why is a trie good for autocomplete?

Follow the typed prefix once, then every word in that subtree is a suggestion.

What is the time complexity of a trie?

Insert, search and delete are O(L), where L is the length of the word.

Trie vs hash table?

A hash table finds exact words fast. A trie also supports prefix queries and ordered output.

How does trie deletion work?

Remove the end marker, then delete nodes upward while they have no children and do not end another word.

What is the downside of a trie?

It can use a lot of memory when words share few prefixes, since each character needs a node.

Is the visualizer free and private?

Yes. Free, no signup, and everything runs in your browser.

More free tools from KickSolve

Other tree visualizers.