Must-know binary tree formulas

1. Properties of general binary trees 
1. On the i level of a non-empty binary tree, there are at most 2^i nodes. 
Property 2. In a binary tree of height K, there are at most 2^(k+1)-1 nodes. 
Property 3. For any non-empty binary tree, if the number of leaf nodes is n0 and the number of nodes with degree 2 is n2, then n0=n2+1. 
2. Definition of complete binary tree 
: If in a binary tree, only the lowermost two layers of nodes have degrees less than 2, the degrees of the other layers are equal to 2, and the nodes of the lowermost layer are concentrated on the leftmost of the layer. in several positions, the binary tree is called a complete binary tree. 
Property 1. The height k of a complete binary tree with n nodes is [log^2n]. 
Property 2. For a complete binary tree with n nodes, if all nodes in the binary tree start from 0 to n-1 in the order from top (root node) to bottom (leaf node) and from left to right Numbering, for any node with subscript i, there are: 
(1) If i=0, it is the root node, and it has no parent node; if i>0, then its parent node's The subscript is (i-1)/2. 
(2) If 2i+1<=n-1, the subscript of the left child of the node with subscript i is 2i+1; otherwise, the node with subscript i has no left child. 
(3) If 2i+2<=n-1, the subscript of the right child of the node with subscript i is 2i+2; otherwise, the node with subscript i has no right child. 
3. Definition of a full binary tree 
: If any node of a binary tree is either a leaf or has two non-empty subtrees, the binary tree is called a full binary tree. 
Properties: In a full binary tree, the number of leaf nodes is one more than the number of branch nodes. 
4. Expand the binary tree 
Definition: An expanded binary tree is an expansion of an existing binary tree. After the expansion, the nodes of the original binary tree become branch nodes with degree 2. That is to say, if the degree of the original node is 2, it will remain unchanged; if the degree is 1, one branch will be added; if the degree is 0, two branches will be added. 
Property 1. In an augmented binary tree, the number of external nodes is 1 more than the number of internal nodes. 
Property 2. For any extended binary tree, the following relationship is satisfied between the external path length E and the internal path length I: E=I+2n, where n is the number of internal nodes.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325939726&siteId=291194637