Contents
ToggleTrees and arboresences
Trees and arborescences are particular graphs often used to represent thehelp with the decision, data, or for calculating the complexity.
Terminology
For example, calculators organize the expressions math depending on the priority of the operators and their depth: (y/2 – x)*(75+z) will be represented by <*,<-,,>,>,<+,,>>. The operation is then done by a particular traversal of the tree:
- the descendants of a node are the nodes of its subtrees;
- an ancestor of a node is either its father or an ancestor of its father;
- the path from a node to the root is made up of all its ancestors;
- the brother of a node is a son of his father other than himself.
A tree is often represented by a graph to make it easier to read:
The nodes of a tree are distributed by depths (or levels). The depth 0 contains only the root, the depth 1 its children etc. The height of a tree is the number of depths, or the size of the longest path from a node to the root.
Definition: graph theory
Given an undirected graph comprising not vertices, the following properties are equivalent:
- The graph is connected and without cycle,
- The graph is cycleless and has n-1 edges,
- The graph is connected and admits n-1 edges,
- The graph is cycleless, and by adding an edge, then we create one and only one elementary cycle,
- The graph is connected, and by removing any edge it is no longer connected,
- There is one chain and only one between all pairs of vertices.
A tree is a directed graph without circuit admitting a root such that for any other vertex there is a unique path from the root to this vertex. A tree has properties similar to a tree.
Binary tree
Let us determine the total number of leaves and nodes of a complete binary tree.
At depth 0 there is a leaf, the root. Suppose the complete binary tree has 2(h-1) leaves up to the task h. So, at the height h + 1, each of these leaves becomes a node with two threads, so we have a number of leaves of 2 * 2(h-1) = 2h. CQFD.
In addition, the number of nodes of the complete binary graph is equal to the sum of the leaf number of the complete binary trees of lower height. We deduce that the total number of node is ∑(i = 0)(h-1) 2i = 2h -1. Conversely, if a complete binary graph has n nodes, then its height is according to the preceding formula log2 (n) +1. We deduce that any binary tree has at least log height2 (n) +1.
The indicator on the vertices shows the difference between the height of the left subtree and the height of the right subtree.
When the tree is unbalanced, it is then necessary to swap the parent vertices and the root while maintaining the order of the sub-trees (see the continuation on research trees).
We can enlarge the definition on trees of higher degree (ternary tree etc). Only the coefficient 2 is modified according to the number of wires defined by the type of shaft.
Research tree
A search tree is a data structure making it possible to represent a set of values if we have an order relation on them. The standard operations on search trees are: inserting, deleting or finding a value. These operations are inexpensive if the shaft is balanced. In order to facilitate understanding, we will work on binary search trees (ABR).
The smallest value is the last left descendant of the root, and the largest is the last right descendant of the root. Other logical criteria can be deduced from the definition:
The three actions are then carried out through ABR routes.