Recall & Review
beginner
What is a Trie data structure?
A Trie is a tree-like data structure used to store a dynamic set of strings where keys are usually strings. Each node represents a character, and paths from root to leaves represent words.
Click to reveal answer
beginner
How does a Trie help in word search?
A Trie allows fast prefix-based search by traversing nodes corresponding to characters of the word. It can quickly check if a word or prefix exists by following the path in the Trie.
Click to reveal answer
intermediate
What is the time complexity of searching a word in a Trie?
The time complexity is O(m), where m is the length of the word being searched, because we check one character at each level of the Trie.
Click to reveal answer
beginner
Explain how to insert a word into a Trie.
Start from the root node. For each character in the word, check if a child node exists. If not, create a new node. Move to the child node and continue. Mark the last node as the end of a word.
Click to reveal answer
beginner
What does it mean if a node in a Trie is marked as 'end of word'?
It means that the path from the root to this node forms a complete valid word stored in the Trie.
Click to reveal answer
What does each node in a Trie represent?
✗ Incorrect
Each node in a Trie represents a single character of a word.
What is the main advantage of using a Trie for word search?
✗ Incorrect
Trie allows fast prefix-based search by traversing nodes corresponding to characters.
What is the time complexity to search a word of length m in a Trie?
✗ Incorrect
Searching a word in a Trie takes O(m) time, where m is the word length.
When inserting a word into a Trie, what do you do if a character node does not exist?
✗ Incorrect
If a character node does not exist, create a new node for it.
What does marking a node as 'end of word' signify in a Trie?
✗ Incorrect
Marking a node as 'end of word' means the path from root to this node forms a valid word.
Describe how to search for a word in a Trie step-by-step.
Think about following the path of characters from root to leaf.
You got /5 concepts.
Explain why Tries are efficient for prefix-based word searches.
Consider how words with same start share parts of the Trie.
You got /5 concepts.