Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 08 · DSA · Worked problems, in English · about 19 min to read

Play it as a journeyTutor comes with a plan

Clinic #23: Implement Trie

Trees
Trees · Open board

The last corner of this drawing is the one this clinic needs: words spelled downwards one letter per step, where “cat” and “car” walk the same first two steps and only split at the third.

Before you start. A tree, from Trees (BST, balancing, heaps, tries), is a shape with one starting point at the top, branches going down, and nothing ever looping back up. A hash set, from Hashing, is a box that answers “is this exact thing in here?” in one step, however full the box is. This clinic needs nothing else.

Lesson 62 of 96 in DSA

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • The problem: a suggestion bar that must keep up with your thumb
  • By hand: three words and the question “does anything start with ap?”
  • The first idea: keep a list and check every word
  • The second idea: write down every prefix in advance
  • The tell: “starts with” in the problem statement
  • Each crossroads is a node, and the first one is the root
  • The star: the end-of-word flag that tells “app” from “apple”
  • Three operations, one walk
  • The three solutions
  • Measured: time
  • Measured: memory, and one long word
  • The bug the example is built to catch
  • The complexity table
  • Interview path, first time
  • The trie ladder

Terms it explains: no, prefix, once, trie, node, root, end-of-word flag, O(L), Word Search II, B-tree, balanced, binary tree, BST, complete tree, heap, height h, priority queue, rotation, self-balancing BST (AVL / red-black), sift up/down, traversal, tree.

Review DSA