Skip to content
playdsa
Preferences

Make yourself comfortable.

Saved on this browser. Your device’s reduced-motion preference is always respected.

Theme
Advanced settings
Back to syllabus

Tries and Prefix Search

4 chapters · 6 challenges · The Glyph Garden

Understand the idea, practise through play, then prove it in code. Choose your next quest below.

Visual introduction to this topic
Start here · 3 minute mental model

What is a trie?

A trie is a tree whose edges represent characters or tokens. Words with the same prefix share the same opening path, making prefix queries proportional to the query length.

Think of autocomplete paths. Typing c → a reaches the shared branch for cat, car, and care. The structure does not restart from every word.

Shared prefixes become shared paths; word endings need an explicit marker.

One edge per token

Following a word costs O(length), independent of how many other words exist.

Prefix is not a word

Store an end marker so car and cart can both exist.

Wildcards branch

An unknown character may require exploring every matching child.

What you will learn firstShared Glyphs

Walk the common prefix

Begin the guided lesson

Your chapter route

Shared Glyphs

Continue
Source reviewed

Built from authoritative material

This track is checked against the sources below. Visual traces still carry their own complete or guided coverage label, so unfinished explanations are not presented as complete executions.

Help shape PlayDSA

Something confusing, broken, or missing? Leave a quick note without leaving your lesson.

Please leave out passwords, payment details and other private information.

Page included: /

Sign in to save feedback here, or send it with your email app. Your draft stays here while you sign in.

Open email instead