Search code examples
data-structurestrie

Should searching for a substring of a key in a trie return true?


Say I have an empty trie T, and then I do T.insert("hello"). If I perform T.find("hell") then is that supposed to return true or false?


Solution

  • It should return all the partial matches, so in the case you're talking about should return {"hello"}, if it doesn't have a match would normally expect it to be an empty set being returned or null