Two-fork Tree

Source: Internet
Author: User

1 definitions

Binary tree is a finite set of n (n >= 0) nodes, either an empty set (called an empty binary tree), or a root node and two Saozi right subtrees, called root nodes, that are disjoint.

22 Characteristics of the fork tree

(1) Each node has a maximum of two sub-trees, so there is no node in the binary tree with a degree greater than 2.

(2) Saozi right subtree is in order, the order cannot be reversed.

(3) Even if there is only one subtree in the tree, distinguish between Zuozi and right subtree. The two trees are different two binary trees.

(4) The binary tree has five basic forms: The Empty binary tree, only one root node, the root node only Zuozi, the root node only the right subtree, the root node has both the left dial hand tree, but also has the right sub-tree.

The three nodes of the tree will have the following five forms:

3 Special two-fork tree

(1) Oblique tree: All nodes are only Zuozi of the two-fork tree called the Left oblique tree. All nodes have only the right subtree of the two-tree called the right oblique tree. If 2 is left oblique tree, Figure 5 is right oblique tree.

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

(3) Complete binary tree: A two-fork tree with n nodes, according to the sequence automatic arranging, if the node numbered I and the same depth of the full two-fork tree is numbered in the same position in the binary tree, then this binary tree is called a complete binary tree.

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

Features of the complete binary tree:

(a) The leaf node intelligence appears on the bottom two layers.

(b) The lowest-level leaves must be concentrated in the left-hand continuous position.

(c) The bottom two layer, if there are leaf nodes, must be concentrated in the right continuous position.

(iv) If the node degree is 1, then the node is only left child and there is no node for the right child.

(v) The two-fork tree of the same node tree, the depth of the complete binary tree is minimal.

42 The nature of the fork tree

(1) On the first layer of the binary tree, there are at most 2^ (i-1) nodes.

(2) A two-fork tree with a depth of K, at most 2^k-1 nodes.

(3) For any binary tree, if its terminal node (leaf node) tree is N0, the degree of 2 node is N2, then n0=n2 + 1.

Analysis: The degree of 2 of the node is N2, the degree of 1 of the node is N1, the degree of 0 of the node is n0, then two fork tree node total n0+n1+n2.

A node with a degree of 2 has a total of 2*n2 sub-nodes, a node with a degree of 1 N1 sub-nodes, and a root node, and a binary tree node tree has a total of 2*n2 + N1 +1.

So n0+n1+n2 = 2*n2 + n1 +1, i.e. N0=n2 + 1.

(4) The depth of a complete binary tree with n nodes is [log2n]+ 1. (log with base n of 2, [x] = maximum integer not greater than X)

(5) A complete binary tree with n nodes, numbered by node sequence, to any node I (1<=i<=n)

(a) If i=1, then the node is the root node.

(b) If the node I has left child, then the left child's node is 2*i, if has the right child, then has the child's knot is 2*i+1.

Two-fork 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.