Tries & Search-as-you-type
In short: a trie (said "try", from retrieval) is a tree whose edges
are characters. Every title is a path down from the root, and titles that
begin the same way share the start of that path — so a prefix is found in as
many steps as it has characters, no matter how many titles the trie holds.
Each node holds a dict of children and an is_end flag marking whether a
title ends exactly there; without that flag, every prefix of every real
title would wrongly pass as a title too. search(word) is node is not None and node.is_end; starts_with(prefix) only needs node is not None. Both
cost O(m) for m characters.

Complete a title before the next keystroke
Type "ne" into Tunebox's search box and suggestions should appear before the
next key is pressed. Checking title.startswith("ne") against every title
works for a few hundred songs, but with millions, every keystroke rescans
the lot. A trie's node holds a dict of children and the end flag:
A trie holding glow, neo, neon and net, where ● marks a node at which a title ends, and typing a prefix walks one edge per character.
Every lookup starts at the root, which all four titles share. Binary tree, 10 nodes, height 5. At node root.
(Each node here has at most two children only because this example is small; a trie node can have one child per possible character.)