1.

What is the advantage of a ternary search tree over trie?

Answer»

In contrast to the trie(STANDARD) data structure, which has 26 pointers for its offspring, every node in a ternary search tree only has three:

  • The left pointer is pointing to the node WHOSE value is lower than the current node's value.
  • The equal pointer leads to a node whose value is the same as the current node's value.
  • The right pointer leads to the node whose value exceeds the current node's value.

Aside from the three-pointers mentioned above, every node has a field for indicating data (character in the case of a dictionary) and a field for indicating the end of a string.

One advantage of employing ternary search trees over attempts is that ternary search trees take up less space (only three-pointers each node in comparison to 26 in standard tries). In addition, ternary search trees can be utilised in any situation where a hashtable is used to hold strings. Tries are appropriate whenever there is a balanced mix of words throughout the alphabets, ALLOWING for the most efficient use of space. Aside from that, ternary search trees are preferable. Whenever the strings to be MAINTAINED all have the same prefix, ternary search trees are the most economical (in terms of space).



Discussion

No Comment Found