Summary of concepts related to the basic definition of tree in data structure

Source: Internet
Author: User
definition

The recursive definition of the tree is as follows (personal preferred definition, from Baidu Encyclopedia): a single node is a tree, the root is the node itself.

T1,t2,.., tk is a tree with root nodes of N1,n2,.., NK respectively. With a new node n as N1,n2,.., NK's father, he gets a new tree, and the node n is the root of the new tree. We call N1,n2,.., NK as a group of sibling nodes, all of which are node N's sub-nodes. We also call T1,t2,.., tk as a subtree of node n.

An empty collection is also a tree, called an empty tree. There are no nodes in the empty tree. related terms (from Wikipedia, with changes)

1, the degree of the node: a node contains the number of sub-tree is called the degree of the node;
2, the degree of the tree: the maximum value of all nodes in a tree is called the degree of the tree;
3, leaf node or end node: zero degree node;
4, non-terminal node or branch node: The node is not zero degrees;

5, Father node or parent node: If a node contains child nodes, then this node is called the parent node of its child nodes;
6, child node or child node: A node contains a subtree of the root node is called the node's child nodes;
7, sibling nodes: nodes with the same parent node are called sibling nodes;

8, the level of the node: Define a tree root node level is 1, the other node hierarchy is its parent node level plus 1;
9. Height or depth of tree: the maximum value of all nodes in a tree is called the depth of this tree;

10, Cousin node: The parent node in the same layer of the nodes are each other cousins;
11, the ancestor of the node: from the root to the node on the branch of all nodes;
12. Descendants: Any node in a subtree that is rooted in a node is called the descendant of that node.
13. Forest: The collection of trees that are not intersected by M (m>=0) is called the forest;

need to be explained below: node = nodes, all originated from the English word node. leaf node = leaf node type

Unordered tree: There is no sequential relationship between the sub-nodes of any node in the tree, which is called the unordered tree, also known as the free tree;
Ordered tree: There is a sequential relationship between the sub-nodes of any node in the tree, which is called ordered tree;

Binary tree: A tree with a maximum of two subtrees per node is called a binary tree;
Binary search tree (binary sort tree)
Complete binary Tree
Full two fork Tree
Balanced two-pronged tree
Hoffman: The shortest two-fork tree with the right path is called Huffman tree or optimal binary tree;

Red and black Trees
B-Tree representation method

The most intuitive is the tree representation
There is another common method: first put the root node in a pair of parentheses, the root node immediately after a pair of parentheses, and then put its subtree in left-to-right order into the parentheses, the same layer of the subtree separated by commas. As in the preceding tree notation can be expressed as: (1 (2 (4), 3 (5,6)))

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.