A
node is a structure which may contain data and connections to other nodes, sometimes called
edges or
links. Each node in a tree has zero or more
child nodes, which are below it in the tree (by convention, trees are drawn with
descendants going downwards). A node that has a child is called the child's
parent node (or
superior). All nodes have exactly one parent, except the topmost
root node, which has none. A node might have many
ancestor nodes, such as the parent's parent. Child nodes with the same parent are
sibling nodes. Typically siblings have an order, with the first one conventionally drawn on the left. Some definitions allow a tree to have no nodes at all, in which case it is called
empty. An
internal node (also known as an
inner node,
inode for short, or
branch node) is any node of a tree that has child nodes. Similarly, an
external node (also known as an
outer node,
leaf node, or
terminal node) is any node that does not have child nodes. The
height of a node is the length of the longest downward path to a leaf from that node. The height of the root is the height of the tree. The
depth of a node is the length of the path to its root (i.e., its
root path). Thus the root node has depth zero, leaf nodes have height zero, and a tree with only a single node (hence both a root and leaf) has depth and height zero. Conventionally, an empty tree (tree with no nodes, if such are allowed) has height −1. Each non-root node can be treated as the root node of its own
subtree, which includes that node and all its descendants. Other terms used with trees: ==Common operations==