04 Try it yourself Interactive

Draw the trie one character at a time

The Insert tab builds the trie from an empty root, one character per press — plus a press to arrive at the root of each word and a press to set its end-of-word flag — and tells you each time whether a node was created or reused. The Query tab walks a string through the trie you just built and stops to show where search and startsWith part ways. Nothing moves until you press Next.

Insert
from an empty trie
1–4 words, A–Z only, up to 6 letters each.
Press Next to begin. Each press moves one step.


      
Character
Depth0
Reused0
New nodes0
step 0 / 0