algorithm - Compute the binary tree nodes count -


Is it possible to calculate how many nodes have arbitrary binary trees? The count of the leaf and the depth of every leaf is known (it is actually Huffman tree)

I need it so that it can actually allocate the memory required for the tree before the building, and later the memory allocation Can escape.

There is a Huffman tree, that means every node in the tree is either 0 or 2 children, in this case you For K-leafs exactly K-1 internal nodes are required. Therefore, the total number of nodes is 2k - 1.


Comments