Data structure Notes _ The nature of binary tree

Source: Internet
Author: User

The nature of the binary tree:

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

Property 2. A two-fork tree with a depth of K contains up to 2^ (k)-1 nodes (k>=1).

Property 3. For any binary tree, if it contains n0 leaf nodes, N2 nodes with a degree of 2, there must be a relationship n0=n2+1.

Prove:

The total number of nodes on a two-fork tree is n, then n=n0+n1+n2, where N1 is a node with a degree of 1.

The total number of branches on the binary tree b=n1+2*n2;

and b=n-1 (because root node, each node has a point to its branch) =n0+n1+n2-1, thus, n0=n2+1;

Two types of special binary trees:

Full two fork tree: refers to a two-fork tree with a depth of K and contains 2^k-1 nodes.

Complete binary tree: The n nodes contained in the tree correspond to the numbers 1 to n one by one in the tree of two forks. (That is, a tree with a depth of K, its front k-1 layer is full, and the last layer of nodes is arranged from left to right).

Property 4.4. The depth of the complete binary tree of the European N nodes is logn+1.

Data structure Notes _ The nature of binary 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.