
The node q is then termed a descendant of p. A node p is an ancestor of a node q if it exists on the path from q to the root.


Ternary trees are used to implement Ternary search trees and Ternary heaps. Any node in the data structure can be reached by starting at root node and repeatedly following references to either the left, mid or right child. Outside the tree, there is often a reference to the "root" node (the ancestor of all nodes), if it exists. Nodes with children are parent nodes, and child nodes may contain references to their parents. 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".

A simple ternary tree of size 10 and height 2.
