Question

In: Computer Science

Give a proof by induction that the number of nodes of a full binary tree with...

Give a proof by induction that the number of nodes of a full binary tree with a height of "h" is: (2^(h+1))-1.

Solutions

Expert Solution

Answer : Given data

* The number of nodes of a full binary tree with a height of "h" is: (2^(h+1))-1.

* Base Case: h = 0. As above, a tree of height 0 has exactly one node, and 2^(0+1) - 1 = 2^1 - 1 = 2 - 1 = 1, so the base case satisfies the Induction Hypothesis. Induction Hypothesis: * Spose that the result holds for some k >= 0; i.e., a binary    search tree of height k has at most 2^(k+1) - 1 nodes. 
 * Induction Step: Let T be a binary tree of height k+1. By definition of leaf, all the nodes at depth k+1 are leaf nodes.    * As we know there are at most 2^(k+1) leaves. If we remove all the leaves, we are left with a tree of height k. 
* Thus the total number of nodes in T is at most 2^(k+1) [for the leaves] + 2^(k+1) - 1 [for the remaining tree of height k, by the I.H.] = 2*(2^(k+1)) - 1 = 2^(k+1+1) - 1.
*  Hence the hypothesis holds for k+1, and so the theorem is proved.

_____________THE END______________


Related Solutions

Write a solution to return the count of the number of nodes in a binary tree....
Write a solution to return the count of the number of nodes in a binary tree. Your method will be passed one parameter, a copy of a pointer to the root node of the tree (Node *) and will return an int that is the count of nodes. If the tree is empty, return 0 (this is the recursive base case).
Write a binary search tree and include the functions to find the number of nodes and...
Write a binary search tree and include the functions to find the number of nodes and the height of the tree. Test your code in main. Print the post-order, in-order and pre-order traversal. in c++ please.
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?
the following lists the nodes in a binary tree in two different orders: Preorder : A...
the following lists the nodes in a binary tree in two different orders: Preorder : A B C D E F G H I J K L M Inorder : C E D F B A H J I K G M L Draw the binary tree
Prove that the proof by mathematical induction and the proof by strong induction are equivalent
Prove that the proof by mathematical induction and the proof by strong induction are equivalent
10) A binary tree with N nodes is at least how deep? How deep is it...
10) A binary tree with N nodes is at least how deep? How deep is it at most? 12) A Binary Search Tree is a binary tree with what additional property? 13) Beginning with an empty binary search tree, insert the following values in the order given. Draw the tree at each step of the process. 1 10 5 20 22 7 14) Now delete the value 10 from the tree in question 13. Show each of two possible configurations...
Write a O(n) method valuesInLevelOrder() that returns a list of the nodes of a binary tree...
Write a O(n) method valuesInLevelOrder() that returns a list of the nodes of a binary tree in level-order. That is, the method should return the root, then the nodes at depth 1, followed by the nodes at depth 2, and so on. Your algorithm should begin by putting the tree root on an initially empty queue. Then dequeue a node, add it to the output, and enqueue its left and right children (if they exist). Repeat until the queue is...
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
Name three similarities or differences between a balanced tree, complete tree and full binary tree.
Name three similarities or differences between a balanced tree, complete tree and full binary tree.
Use proof by contradiction to show that a cycle graph with an odd number of nodes...
Use proof by contradiction to show that a cycle graph with an odd number of nodes is not 2-colorable.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT