Question

In: Computer Science

a tree is binary, if every node has at most two children nodes. prove that the...

a tree is binary, if every node has at most two children nodes. prove that the maximum of nodes in a binary tree of height h is 2^(h+1)-1

Solutions

Expert Solution

We want to show that maximum of nodes in a binary tree of height h is 2(h+1)-1.

We want to find the maximum number of nodes of binary tree,which means that the binary tree is completed.

For level 1 of complete binary tree,number of nodes=1=20

for level 2,number of nodes=2=21

for level 3,number of nodes =4=22

for level 4,number of nodes=8=23

.

.

.

for level h,number of nodes=2h

Total number of nodes in a complete binary tree will be,

                                            =20+21+22+24+.....+2h

                   = from the equation of sum of geometrical progression=    ,where a is the first term,r is the common ratio and n is the number of terms.        

= 2(h+1)-1

Hence proved.

   


Related Solutions

A binary tree is a rooted tree in which each node has at most two children....
A binary tree is a rooted tree in which each node has at most two children. Show by induction that in any binary tree the number of nodes with two children is exactly one less than the number of leaves.
Prove that the entropy of a node never increases after splitting it into smaller children nodes.
Prove that the entropy of a node never increases after splitting it into smaller children nodes.
Write a binary search tree with 10 nodes in Java, each node will have 3 attributes...
Write a binary search tree with 10 nodes in Java, each node will have 3 attributes (data, x, y). The binary tree need to have function "add()" to add new node into the tree. After added all 10 nodes, it will be sorted and turn into a balanced binary search tree.
(IN C) Write the code to manage a Binary Tree. Each node in the binary tree...
(IN C) Write the code to manage a Binary Tree. Each node in the binary tree includes an integer value and string. The binary tree is sorted by the integer value. The functions include: • Insert into the binary tree. This function will take in as parameters: the root of the tree, the integer value, and the string. Note that this function requires you to create the node. • Find a node by integer value: This function takes in two...
Write a C++ method that traverses through a binary tree (only 2 children to a node)...
Write a C++ method that traverses through a binary tree (only 2 children to a node) using preorder traversal and finds the proper place to put in a new node. The method will take in an int and traverse through the tree to find the proper place but it must use PREORDER traversal to find a proper position. struct node{ int data; struct node* left, *right; Node(int Data){ this->data=data; left=right=NULL; } }; void preorderAdd(int newNum){ //Method to traverse using preorder...
(+5) Level of a node in a binary tree is distance from root to that node....
(+5) Level of a node in a binary tree is distance from root to that node. For example, level of root is 0 and levels of left and right children of the root are 1. Level      Max number of nodes 1 2 4 8 16 32 64 ..      … n       ?? The maximum number of nodes on level n of a binary tree is : A          2^(n-1)                         B          2^n C          2^(n+1)                       D            2^[(n+1)//2] In the above answers, the operator...
A binary tree model with 7 decision nodes will have how many terminal nodes?
A binary tree model with 7 decision nodes will have how many terminal nodes?
Write the code to manage a Binary Tree. Each node in the binary tree includes an integer value and string.
Programming CWrite the code to manage a Binary Tree. Each node in the binary tree includes an integer value and string. The binary tree is sorted by the integer value. The functions include:• Insert into the binary tree. This function will take in as parameters: the root of the tree, the integer value, and the string. Note that this function requires you to create the node.• Find a node by integer value: This function takes in two parameters: the root...
Consider the following type of binary trees: data Tree a = Leaf a | Node (Tree...
Consider the following type of binary trees: data Tree a = Leaf a | Node (Tree a) (Tree a) A tree is balanced if the number of leaves in the left and right subtree of every node differ by at most one. Write a Haskell function balanced that returns whether a tree is balanced or not. balanced :: Tree a -> Bool
Consider the following struct that represents a node within a binary tree: struct Node { int...
Consider the following struct that represents a node within a binary tree: struct Node { int data; // Data of interest Node *left // Link to left subtree (nullptr if none) Node *right ; // Link to right subtree (nullptr if none) }; Complete the following function that computes the number of elements in a binary tree: // Counts the number of elements in the binary tree to which t points. // Returns the number of elements. int size(Node *t)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT