asfasdfasd's blog

By asfasdfasd, history, 8 years ago, In English

What is ternary search tree ??

  • Vote: I like it
  • +9
  • Vote: I do not like it

»
8 years ago, # |
  Vote: I like it -18 Vote: I do not like it

Ternary search tree is a type of trie ( you can get informations about trie from this link ) where nodes are arranged in a manner similar to a binary search tree, but with up to three children rather than the binary tree's limit of two.

Each node of a ternary search tree stores a single character, an object, and pointers to its three children middle_child, lower_child and higher_child. A node may also have a pointer to its parent node as well as an indicator as to whether or not the node marks the end of a word. The lower_child pointer must point to a node whose character value is less than the current node. The higher_child pointer must point to a node whose character is greater than the current node. The equal middle_child points to the next character in the word.

For example : The figure below shows a ternary search tree with the strings "as", "at", "cup", "cute", "he", "i" and "us":


c / | \ a u h | | | \ t t e u / / | / | s p e i s