implemented trie data structure