use a trie. It's a compressed tree. Depending on how long the word you're using for the index is, you will get to it in time k where k equals word.length.