Which statement best describes how a trie stores prefixes of words?
Think about how characters connect in a trie to form words and prefixes.
In a trie, each node represents a character. The path from the root to any node forms a prefix of some word(s). This structure allows efficient prefix matching.
What is the maximum number of children a single node in a trie can have when storing English lowercase words?
Consider the English alphabet letters used in the words.
Each node can have up to 26 children, one for each lowercase English letter from 'a' to 'z'.
Given a trie storing words, which step is necessary to find all words starting with a prefix "pre"?
Think about how to reach the prefix node and then find all words below it.
To find all words with a prefix, first follow the prefix characters in the trie to reach the node representing the prefix. Then collect all words in the subtree rooted at that node.
What is the time complexity to check if a prefix of length k exists in a trie storing n words?
Consider how many nodes you visit when searching for a prefix.
Checking a prefix requires traversing nodes equal to the prefix length k. This is independent of the total number of words n.
Which statement best explains a common memory trade-off when implementing tries for prefix matching?
Think about how children nodes are stored and accessed in tries.
Arrays allocate fixed space for all possible children, using more memory but enabling quick direct access. Linked lists save memory by storing only existing children but require slower traversal.