A prefix tree stores words as paths from root. Given the set {cat, car, canine, cart}, which operation best guarantees a match for the prefix ‘ca’ while avoiding false positives beyond existing words?
- Check if any word starts with ‘ca’ by counting children
- Search for ‘ca’ exactly and return associated word
- Look up a hash map of two-letter keys for prefixes
- Traverse from root using ‘c’ then ‘a’ and check terminal flag
0
voters
Vote, then reply with how you reasoned it out. The answer goes up in about a day.