Ternary tree

In computer science, a ternary tree is a tree data structure in which each node has at most three child nodes, usually distinguished as "left", “mid” and "right".

be the maximum number of nodes in a ternary tree of height h –

In Ternary trees, a node that is inserted is specified as to which child it is.

Deletion is the process whereby a node is removed from the tree.

Only certain nodes in a ternary tree can be removed unambiguously.

If a node has no children (external node), deletion is accomplished by setting the child of A's parent to null and A's parent to null.

The picture below is a binary search tree that represents 12 two-letter words.

To find the word "ON", we compare it to "IN" and take the right branch.

In a tree representing words of lower case letters, each node has 26-way branching.

At every node, one accesses an array element, tests for null, and takes a branch.

The above picture is a balanced ternary search tree for the same set of 12 words.

A search for the word "IS" starts at the root, proceeds down the equal child to the node with value "S", and stops there after two comparisons.

A simple ternary tree of size 10 and height 2.