Trie-based memo functions