Java Data Structure Series--Tree (1): A summary of the basic concepts and characteristics of two fork trees

Source: Internet
Author: User

The concept of degrees: the number of sub-trees that a node has is called the degree of Node (degree). Nodes with a degree of 0 are called leaf nodes (leaf) or terminal nodes. Nodes with a degree of not 0 are called non-terminal nodes or branch nodes. root node, branch nodes are also called internal nodes. The degree of the tree is the maximum value of the degree of the inner node of the tree.

The depth or height of a tree: the level of the node is defined from the root, and the root is the first layer, and the child of the root is the second layer. The maximum level of nodes in a tree is called the depth or height of the tree.

Representation of the Tree: (1) Parental representation (2) Child Representation (3) Child brother representation

Binary tree: The two fork tree is a finite set of n (n>=0) nodes, either an empty set (called an empty binary tree) or a two-fork tree consisting of a root node and two disjoint Saozi right subtrees, called the root nodes, respectively.

Binary Tree Features: (1) Each node has a maximum of two subtrees trees, so the binary tree does not exist in the degree of more than 2 nodes, attention is not only two subtrees tree, but at most. It is possible to have no subtree or a subtree.

(2) Saozi right subtree is in order, the order can not be arbitrarily reversed.

(3) Even if there is only one subtree in the tree, it is Zuozi or right subtree to distinguish it from another tree.

The binary tree has 5 basic forms: (1) empty binary tree (2) Only one root node (3) root node only Zuozi (4) root node only the right subtree (5) root nodes have both left subtree and right subtree.

Three special two-fork Trees: (1) Oblique tree: All nodes are only Zuozi two fork tree called Left oblique tree. All nodes are only right subtree of two forks tree called Right oblique tree

(2) Full two fork tree: In a binary tree, if all branch nodes have left subtree or right subtree, and all leaf nodes are on the same layer, such a two-fork tree is called full two fork tree.

                      &NBS P                          ,         &NB Sp Full two fork tree has the following characteristics: A leaves can only appear in the next layer. It is impossible to reach equilibrium at other levels; The degree of the non-leaf node is 2;c in the same depth of the two-fork tree full                                    ,         &NB Sp                 Two The tree has the largest number of nodes and leaves the tree at its lowest point.

(3) Complete binary tree: A two-fork tree with n nodes is numbered according to the sequence number, if the node numbered I (1<=i<=n) and the node with the same depth in the full two fork tree are located in the binary tree position in the complete phase , the binary tree is called a complete binary tree;

Full two fork tree must be a completely binary tree, but a complete binary tree is not necessarily full.

The complete binary tree has the following characteristics: 1 leaf nodes can only appear at the bottom two layers; 2 The bottom leaves must be concentrated in the left continuous position; 3 The second-lowest, if there is a leaf knot point must appear right 4 If the node degree is 1, then there is only the left child, that is, there is no only right subtree, and 5 the same node two fork tree, the depth of the complete binary tree is the smallest;

The nature of the binary tree:

Properties 12 The number of nodes on the first layer of a fork tree is up to 2i-1 (i≥1).

A two-tree with a 2 depth of K has a maximum of 2k-1 nodes (k≥1).

Property 3 In any-tree binary tree, if the number of terminal nodes is N0, the degree of 2 of the node is N2, then no=n2+1.

Property 4 The depth of a complete binary tree with N nodes is

Property 5 If the nodes of a complete binary tree with n nodes are numbered in sequence, any node I (1<=i<=n) has: 1 if i=1, then node i is the root of two fork tree, no parents, if i>1, then the parents are nodes; 2 if 2i> N, the node I have no left child, otherwise its left child is node 2i;3 if 2i+1>n, then node I no right child, otherwise the right child is node 2i+1;



Java Data Structure Series--Tree (1): A summary of the basic concepts and characteristics of two fork trees

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.