Tree definition and related concepts

Source: Internet
Author: User

A tree is a finite set of n (n> = 0) nodes. When n = 0, it is an empty tree. In any non-empty tree: (1) there is only one specific node called root; (2) When n> 1, other nodes can be divided into M (M> 0) finite sets that do not conflict with each other T1, T2 ,........ TM, in which each set is itself a tree and is called a root subtree ).

Two points must be emphasized for the tree definition:

1. n> 0, the root node is unique and it is impossible to have multiple root nodes.

2. m> 0, there is no limit on the subtree, but they must be different from each other.

Node Classification

1. the node of the tree contains a Data Element and several branches pointing to the subtree.

2. The number of Subtrees owned by a node is called the degree of a node (degree ).

3. A node with zero degree is called a leaf node or a terminal node.

4. A node whose degree is not zero is called a non-terminal node or a branch node.

5. Apart from the root node, the direct points are also called internal nodes.

6. The tree degree is the maximum degree of each node in the tree.

Relationship Between Nodes

1. The root of the Child tree of a node is the child of the node, which is called the child's parent ).

2. The children of the same parent are called siblings ).

3. The ancestor of a node is all the nodes on the branch from the root to the node.

4. Any node in the subtree with a node as the root is called the child of the node.

Other related concepts of the tree

1. The level of a node is defined from the root. The root layer is called the first layer, and the child of the root layer is the second layer.

2. If a node is in the I layer, the root of its sub-tree is in the I + 1 layer.

3. the nodes of the two parents on the same layer are cousins.

4. The maximum hierarchy of nodes in the tree is called the depth or height of the tree.

5. Forest (forest) is a set of M (M> = 0) numbers that do not match each other. For each node in the tree, the set of its Subtrees is the forest.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.