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. It allows fast retrieval of words by their prefixes.
Click to reveal answer
beginner
How does a Trie help in prefix search?
A Trie stores words by their characters in a tree. Searching for a prefix means following the path of characters in the Trie. If the path exists, all words below that node share the prefix.
Click to reveal answer
intermediate
What is the time complexity of searching a prefix in a Trie?
The time complexity is O(m), where m is the length of the prefix. This is because we only traverse the Trie nodes corresponding to the prefix characters.
Click to reveal answer
beginner
In a Trie node, what does each child represent?
Each child represents a possible next character in the stored words. For example, if the node has a child for 'a', it means some word continues with 'a' from this point.
Click to reveal answer
intermediate
What is the main difference between a Trie and a Hash Map for prefix search?
A Trie supports efficient prefix search by structure, allowing retrieval of all words with a given prefix. A Hash Map does not support prefix search efficiently because it hashes whole keys, not prefixes.
Click to reveal answer
What does each node in a Trie typically store?
✗ Incorrect
Each Trie node stores a character and links to child nodes representing next characters.
What is the first step to search for a prefix in a Trie?
✗ Incorrect
Searching a prefix means following the path of prefix characters in the Trie.
If a prefix path does not exist in a Trie, what does it mean?
✗ Incorrect
If the path for prefix characters is missing, no stored word has that prefix.
What is the main advantage of using a Trie for prefix search?
✗ Incorrect
Trie allows prefix search in time proportional to prefix length, which is efficient.
Which of these is NOT true about Tries?
✗ Incorrect
Tries do not use hashing; they use tree structure for storing characters.
Explain how a Trie is used to find all words starting with a given prefix.
Think about following characters step-by-step and then exploring below.
You got /4 concepts.
Describe the structure of a Trie node and how it supports prefix search.
Focus on what each node holds and how it connects to others.
You got /4 concepts.