Taocp_2.3_ Tree

Source: Internet
Author: User

1. Tree

A tree is a finite set T of one or more nodes, which makes:

A) There is a specially specified node, called the root of the tree (T), and:

b) The remaining nodes (excluding the root) are divided $m \geq 0$ disjoint set $t_1, ..., t_m$, and each of these sets is also a tree. Tree $t_1, ..., t_m$ called a subtree of this root.

2. degree

The number of sub-trees of a node is called the degree of that node.

Nodes with a degree of 0 are called end (end) nodes, or sometimes called leaves.

A non-final node is usually called a branch node.

As opposed to T, the level of a node is recursively defined as:

The root (t) level is 0, and the level of any other node is greater than 1 for the corresponding node of the subtree that contains the root (t) of the node.

3. Ordered Tree

If the relative order of the subtree $t_1, ..., t_m$ in definition B) is important, we say that the tree is an ordered tree;

If you treat two trees that are not just the relative order of the node tree as different trees, it is said that such trees are directed because they are only considering the relative direction of the nodes, not their order.

Unless explicitly stated, all the trees discussed in this book are orderly.

4. Forest

A forest is a collection of 0 or more disjoint trees (usually an ordered collection). Another way to express the definition of Part B) is to say that all nodes except the root of the tree form the forest.

The difference between the abstract tree and the forest is very small. If we delete the root of the tree, we have a forest; Conversely, if you add a node to any forest and take the tree in the forest as a subtree of the new node, we get a tree. Thus, in informal discussions about data structures, trees and forests are usually almost interchangeable.

5. Two fork Tree

A tree of up to two subtrees per node, called a binary tree, and when there is only one subtrees tree, we distinguish the Saozi right subtree. To say more formally:

A binary tree is an ordered set of nodes, either empty or composed of two elements of a disjoint two-tree that are called left and right subtrees by the root of root and.

Note: Two the fork tree is not a special case of a tree; it is a completely different concept: Two The tree can be empty, but the tree cannot.

Taocp_2.3_ Tree

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.