Recall & Review
beginner
What is a Trie data structure?
A Trie is a tree-like data structure that stores strings by sharing common prefixes. Each node represents a character, and paths from root to leaves represent words.
Click to reveal answer
beginner
Why can't a Hash Map efficiently handle prefix searches on strings?
Hash Maps store keys as whole strings and do not share prefixes. They cannot quickly find all keys starting with a prefix without checking every key, making prefix search inefficient.
Click to reveal answer
intermediate
How does a Trie improve prefix search compared to a Hash Map?
A Trie stores strings by characters in a tree, so all words with the same prefix share the same path. This allows fast prefix search by traversing the prefix path once.
Click to reveal answer
beginner
What is a real-life example where Trie is better than Hash Map?
Autocomplete in search engines uses Trie to quickly find all words starting with typed letters, which is slow with Hash Maps because they lack prefix sharing.
Click to reveal answer
intermediate
What is a limitation of Hash Maps when storing many strings with common prefixes?
Hash Maps store each string separately without sharing prefix parts, leading to higher memory use and slower prefix queries compared to Tries.
Click to reveal answer
What does a Trie node typically represent?
✗ Incorrect
Each Trie node represents one character, building paths for strings.
Why is prefix search inefficient in a Hash Map?
✗ Incorrect
Hash Maps treat keys as whole units, so prefix search requires checking all keys.
Which data structure is best for autocomplete features?
✗ Incorrect
Trie efficiently supports prefix queries needed for autocomplete.
What is a key advantage of Trie over Hash Map for strings?
✗ Incorrect
Trie shares prefixes, saving memory and enabling fast prefix search.
Which operation is NOT efficient in a Trie?
✗ Incorrect
Trie is not designed for random access by index; it is optimized for prefix and exact searches.
Explain why Tries exist and what problems they solve that Hash Maps cannot for string data.
Think about how strings with common beginnings are stored and searched.
You got /4 concepts.
Describe a real-world scenario where using a Trie is better than a Hash Map for handling strings.
Consider typing in a search box and getting instant suggestions.
You got /4 concepts.