1

Take this trie as example:

patricia trie

I want to add the word "luan" to this representation, but luan takes 20 bits to represent, while lua takes 15. So, they "differ" from each other on the 16th bit, but "lua" has no value there to compare. So how would this trie look like?

Jonas
  • 416
  • 4
  • 12
  • 1
    Pretend that all strings are actually terminated with an infinite sequence of 0s.(I.e., if the bit index is out of range, return 0.) That requires reserving the element code 0, but presumably you have at least one unused code. (You don't have to pad with 0, but using a different code makes the enumeration order wonky. If you pad with 1s, you get a variant on lexicographical order where prefixes follow extensions. That's occasionally useful.) – rici Nov 14 '22 at 15:54
  • @rici thanks, my professor confirmed that – Jonas Nov 14 '22 at 23:05

0 Answers0