An interesting property of a non-empty binary tree: n0 = n2 + 1

Source: Internet
Author: User

For any non-empty binary tree T, if n0 represents the number of leaf nodes, the number of non-leaf nodes with a N2 representation of 2, then both satisfy the relationship N0 = n2 + 1.

This is a very interesting nature, so let's prove it.

Proof: First, suppose that the two fork tree has n nodes, then how many edges will it have? The answer is N-1, because in addition to the root node, each of the remaining nodes has only one parent node, then the N nodes contribute to the N-1 edge of the tree. This is the thinking from the bottom up, and from the top down (from the root to the leaf node) thinking, easy to get each node's degrees and 0*n0 + 1*n1 + 2*n2 is the number of edges.

So we have the equation N-1 = n1 + 2*n2, replace N with N0 + n1 + n2, get N0 + n1 + n2-1 = n1 + 2*n2, so there are

N0 = n2 + 1. The proposition is to be proven.

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.