I want to implement a trie to check for the validity of paths, so I would have a tree built that contains all the possible path constructions by breaking it down by directory. So something like /guest/friendsList/search
would go from the root node to it's child guest
, then guest's child friendsList
, and then friendsList's child search
. If search is a leaf node then my string /guest/friendsList/search
would be considered valid.
Is this something a trie would be useful for. All the implementations of tries I've seen deal with individual letters at each node, but can they be whole strings instead? Is a trie specific to this kind of implementation and what I'm trying to do just a basic tree?
Thanks!