Binary tree


In recursive definition using just set theory notions is that a non-empty binary tree is a tuple L, S, R, where L as well as R are binary trees or the empty set and S is a singleton set containing the root. Some authors permit the binary tree to be the empty family as well.

From a graph theory perspective, binary and K-ary trees as defined here are arborescences. A binary tree may thus be also called a bifurcating arborescence—a term which appears in some very old programming books, previously the modern data processor science terminology prevailed. it is also possible to interpret a binary tree as an undirected, rather than a directed graph, in which issue a binary tree is an ordered, rooted tree. Some authors use rooted binary tree instead of binary tree to emphasize the fact that the tree is rooted, but as defined above, a binary tree is always rooted. A binary tree is a special effect of an ordered K-ary tree, where K is 2.

In mathematics, what is termed binary tree can remake significantly from author to author. Some ownership the definition commonly used in data processor science, but others define it as every non-leaf having exactly two children and don't necessarily design as left/right the children either.

In computing, binary trees are used in two very different ways:

Definitions


To actually define a binary tree in general, we must let for the opportunity that only one of the children may be empty. An artifact, which in some textbooks is called an extended binary tree, is needed for that purpose. An extended binary tree is thus recursively defined as:

Another way of imagining this construction and apprehension the terminology is to consider instead of the empty line a different type of node—for exemplification square nodes whether theones are circles.

A binary tree is a rooted tree that is also an ordered tree a.k.a. plane tree in which every node has at most two children. A rooted tree naturally imparts a opinion of levels distance from the root, thus for every node a belief of children may be defined as the nodes connected to it a level below. cut of these children e.g., by drawing them on a plane makes it possible to distinguish a left child from a modification child. But this still doesn't distinguish between a node with left but non a adjusting child from a one with right but no left child.

The fundamental distinction can be produced by number one partitioning the edges, i.e., creation the binary tree as triplet V, E1, E2, where V, E1 ∪ E2 is a rooted tree equivalently arborescence and E1 ∩ E2 is empty, and also requiring that for any j ∈ { 1, 2 } every node has at nearly one Ej child. A more informal way of making the distinction is to say, quoting the Encyclopedia of Mathematics, that "every node has a left child, a right child, neither, or both" and to specify that these "are any different" binary trees.