0

I have to make a dictionary using tries, the number of letters in the alphabet will increase from 26 to 120, and hence the numb er of leaf nodes will increase exponentially. What optimisations can I use so that my lookup, insertion and deletion time doesn't increase exponentially?

EDIT Making the question clearer, sorry for the lack of details I am using a multiway trie like radix tree and making some modifications to it. My question is if I know that the word size will increase (for sure) from 26 to 120, it will increase the depth of the tree. Is it possible to decrease the increase in depth by increasing the key to more than 64 bits (the register can gold maximum 64 bits)?

  • why will it increase exponentially? – Salvador Dali Mar 25 '16 at 03:02
  • It's unclear what you're asking. Is your alphabet expanding, or is the length of the words growing? A concrete example would be helpful. – Jim Mischel Mar 25 '16 at 13:03
  • Initially the trie was designed to handle words of length say 32 chars, now the trie has to handle words of length 120 chars. The length of words is growing. –  Mar 25 '16 at 14:22

2 Answers2

0

It's often better to use binary tries with path compression (Patricia tries) based on the binary representation of your keys. That way you get the benefits of the smallest possible alphabet, and you still only have 2 nodes (one leaf and one internal) per key.

Matt Timmermans
  • 53,709
  • 3
  • 46
  • 87
  • I am making modifications to the way a radix tree is implemented (a multiway trie where M = 2^k) where k is the number of bits used for lookup. If k=6 then it fits the size of registers of the 64 bit CPU Architecture but suppose I increase k to 10, how can I implement that? Note: I want to increase M instead of depth to decrease the time. –  Mar 25 '16 at 05:52
0

Though there may be some optimizations otherwise but our lookup, insertion and deletion time will not increase exponentially. Increasing your alphabet set only means that your each trie node will be bigger now. The path to each word will still have the same length which is equal to the letters in the word.

displayName
  • 13,888
  • 8
  • 60
  • 75