What is ternary search tree ??
# | User | Rating |
---|---|---|
1 | tourist | 3690 |
2 | jiangly | 3647 |
3 | Benq | 3581 |
4 | orzdevinwang | 3570 |
5 | Geothermal | 3569 |
5 | cnnfls_csy | 3569 |
7 | Radewoosh | 3509 |
8 | ecnerwala | 3486 |
9 | jqdai0815 | 3474 |
10 | gyh20 | 3447 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 174 |
2 | awoo | 164 |
3 | adamant | 163 |
4 | TheScrasse | 159 |
5 | nor | 157 |
6 | maroonrk | 155 |
7 | -is-this-fft- | 152 |
8 | Petr | 146 |
8 | orz | 146 |
10 | pajenegod | 145 |
What is ternary search tree ??
Name |
---|
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":