Chapter 17 — It Doesn’t Hurt to Trie

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/34

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 8:07 PM on 7/29/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

35 Terms

1
New cards
Trie
A tree-like data structure used to store and search strings character by character
2
New cards
Trie pronunciation
Trie is usually pronounced like “try”
3
New cards
Prefix tree
Another name for a trie because tries are useful for prefix-based searching
4
New cards
Digital tree
Another name sometimes used for a trie
5
New cards
Trie use case
Autocomplete, prefix searching, dictionaries, IP addresses, and phone numbers
6
New cards
Autocomplete
Suggesting complete words based on a prefix the user has typed
7
New cards
Why tries help autocomplete
They can quickly find the prefix path and collect words below it
8
New cards
Trie node
A node that stores a dictionary or hash table of child links
9
New cards
children dictionary
The hash table inside a trie node that maps characters to child nodes
10
New cards
Root node
The starting node of a trie before any characters are followed
11
New cards
Trie path
A sequence of character links that spells a word or prefix
12
New cards
Child node
The next node reached by following a character key from the current node
13
New cards
Asterisk marker
The "*" key used to show that a complete word ends at that node
14
New cards
Why the asterisk is needed
It separates a complete word from a prefix of a longer word
15
New cards
Complete word vs prefix
A complete word has an asterisk marker, while a prefix may only be part of a longer path
16
New cards
Example of complete word vs prefix
“bat” needs an asterisk even if “batter” continues past the same letters
17
New cards
Shared prefix
When multiple words reuse the same starting path in a trie
18
New cards
Shared prefix benefit
Tries avoid fully repeating the same starting letters for related words
19
New cards
Trie search
Start at the root and follow each character through child nodes
20
New cards
Trie search success
If every character path exists, return the final node
21
New cards
Trie search failure
If a character path does not exist, return None or stop searching
22
New cards
Trie search Big O
O(K), where K is the number of characters in the search string
23
New cards
Why trie search is O(K)
The algorithm checks one character at a time using hash table lookup at each node
24
New cards
Trie search vs binary search
Binary search depends on the number of stored words, while trie search depends on word length
25
New cards
Trie insertion
Add a word by following existing character paths and creating missing nodes
26
New cards
Trie insertion process
Start at the root, process each character, create missing child nodes, then add "*" at the end
27
New cards
Trie insertion Big O
O(K), where K is the number of characters in the word
28
New cards
Collect all words
A recursive process that gathers every complete word below a given trie node
29
New cards
collectAllWords use case
Used after finding a prefix node to gather autocomplete suggestions
30
New cards
Autocomplete process
Search for the prefix, then collect all words below the final prefix node
31
New cards
Trie with values
A trie where the "*" marker stores extra information like a popularity score
32
New cards
Popularity score
A value used to rank autocomplete suggestions by how common or important they are
33
New cards
Smarter autocomplete
Autocomplete that sorts matching words by popularity instead of showing every match equally
34
New cards
Trie tradeoff
Tries can provide fast prefix lookup but may use extra memory for many nodes and child dictionaries
35
New cards
Main lesson of Chapter 17
Tries make prefix-based string searching and autocomplete efficient by storing words as shared character pat