Binary Tree of data structure

Source: Internet
Author: User

Reference blog:

79343914

Common properties of one or two-fork tree

<1> there are up to 2 I-1 nodes on the first layer of a binary tree. (i>=1)

<2>. Two if the depth is K (with K-layer) in the tree, then there are at most 2k-1 nodes. (k>=1)

<3> If the binary tree is numbered from the top to the bottom from left to right, then if a node is numbered K, then the node numbers of the two branches are 2k and 2k+1 respectively.

<4> two fork tree Category: full two fork tree, complete binary tree

<5> In a fully binary tree, the depth of a full binary tree with n nodes is [log2n]+1, where [log2n]+1 is rounded down. The depth of the two-fork tree is k=log2 (n+1);

Full two fork tree: height is h, and a two-fork tree consisting of 2^h-1 nodes is called a full two-fork tree.

Three ways to traverse a two or two-fork tree

(1) Sequence traversal: root node--left dial hand tree, right subtree

(2) Middle sequence traversal: the right subtree, the root node, left dial hand tree

(3) post-post traversal: root node, right subtree, left dial hand tree

The principle of getting the traversal order is to iterate through the method recursively

Binary Tree of data structure

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.