Improving time and space efficiency of trie data structure