Two-fork Tree

Source: Internet
Author: User

Tree structure is a kind of important nonlinear data structure, in which two-tree is more commonly used. The characteristics of the binary tree each node at most only two subtrees tree (no more than 2 nodes in the binary tree), and the binary tree has left and right sub-tree points.

Binary Tree Properties:

1, the binary tree has 5 basic forms, (a) empty binary tree (b) only the root node of the two fork Tree (c) The right subtree is empty two fork tree (d) The subtree is non-empty of the two fork Tree (e) left dial hand tree is empty two

The nature of the binary tree;

Property 1 There are at most 2^ (i-1) nodes on the first layer of the binary tree (i≧1)

Nature 2 Two-tree with a depth of k at most 2^k-1 nodes, (k≧1)

Property 3 for any of the binary tree T, if its terminal node number is n0, the degree of 2 node is n2, then N0 = n2 + 1. (degrees: Refers to the parent node below a few child nodes);

Property 4 The depth of a complete binary tree with n nodes is [㏒?n] + 1

Property 5 If there is a complete binary tree with n nodes (its depth is [㏒?n] + 1) by the sequence number (from the 1th level to the [㏒?n] + 1 layers, each layer from left to right), then to any node I (1≤i≤n), there is

① If i = 1, then node i is the root of the two fork tree, with no parents; if i > 1, then the parent node is [I/2];

② if 2i > N, then node I has no left child (node I is the node of the leaf); otherwise the left child is 2i.

③ if 2i + 1 > N, then it has no children, otherwise its right child's node is 2i + 1

How to traverse a binary tree:

1, hierarchical traversal (from top to bottom, from left to right in order to traverse)

2. Ordinal traversal (preorder (t) = root node of T + preorder (Zuozi of T) + preorder (right subtree of T))

3, Middle sequence traversal (inorder (t) = inorder (t Zuozi) + t root node + inorder (right subtree of T))

4. Post-sequential traversal (postorder (t) = Postorder (Zuozi of T) + postorder (right subtree of T) + t root node)



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.