Proof A) :
Proof by induction.
Base Case:
h = 0.
A binary tree of height 0 has one node.
2h+1 − 1 equals one for h = 0.
Therefore true for h = 0.
Inductive Hypothesis :
Assume that the maximum number of nodes in a binary tree of height h is 2h+1 − 1, for h = 1, 2, ..., k.
Now consider a tree T of height k + 1. The root of T has a left subtree and a right subtree each of which has height at most k. These can have at most 2 k+1 −1 nodes each by the induction hyptohesis. Adding the root node gives the maximum number of nodes in a binary tree of height k + 1,
2(2k+1 − 1) + 1
2 ∗ 2 k+1 − 2 + 1
2 (k+1)+1 − 1
Proof B) :
A complete binary tree of height h has 2h+1 −1 nodes and (include this into the statement to prove) the bottom layer has 2 h nodes.
Base case is the same. Clearly bottom layer has 20 = 1 nodes.
Given a tree of height h+1. Remove the bottom layer, leaving a complete binary tree of height h. By the inductive assumption it has 2h+1 −1 nodes, 2h of which are on the bottom layer. Now add the bottom layer back in.
Clearly this bottom layer has twice as many nodes as the bottom layer of the height h tree,
i.e. 2 2h = 2h+1 nodes and the total number of nodes is
2h+1 −1 + 2h+1 = 2h+2 −1.
Prove this Lemma. Lemma 2.2 A binary tree with height h has at most 2h+1-1 nodes....
2. A complete binary tree is defined inductively as follows. A complete binary tree of height 0 consists of 1 node which is the root. A complete binary tree of height h +1 consists of two complete binary trees of height h whose roots are connected to a new root. Let T be a complete binary tree of height h. Prove that the number of leaves of the tree is 2" and the size of the tree (number of nodes...
A binary search tree includes n nodes and has an height h. Check all that applies about the space complexity of TREE-MINIMUMX) TREE-MINIMUM () 1 while x. left NIL 2 3 return x x x.left O it is e (lg n) ■ it is 0(h). D it is e (1) ■ It is in place ■ it is Θ (n) A binary search tree includes n nodes and has an height h. Check all that applies about the space complexity...
Show that the tree height of a height-balanced binary search tree with n nodes is O(log n). (Hint: Let T(h) denote the fewest number of nodes that a height-balanced binary search tree of height h can have. Express T(h) in terms of T(h-1) and T(h-2). Then, find a lower bound of T(h) in terms of T(h-2). Finally, express the lower bound of T(h) in terms of h.)
Trees and Heaps 1. Show that the maximum number of nodes in a binary tree of height h is 2h+1 − 1. 2. A full node is a node with two children. Prove that the number of full nodes plus one is equal to the number of leaves in a nonempty binary tree. 3. What is the minimum number of nodes in an AVL tree of height 15? 4. Show the result of inserting 14, 12, 18, 20, 27, 16,...
C++ DATA structure Exercise 6.1. Prove that a binary tree having n ≥ 1 nodes has n − 1 edges.
Prove by mathematical induction that а. h log2 for any binary tree with height h and the number of leaves I b. h > log3 ] for any ternary tree with height h and the number of leaves I.
(2 points) A full binary tree has a start node, internal nodes, and leaf nodes. The number of leaf nodes of this binary tree is 256. a) What is the height of the tree? b) How many internal nodes are in this tree?
Refer to the definition of Full Binary Tree from the notes. For a Full Binary Tree T, we use n(T), h(T), i(T) and l(T) to refer to number of nodes, height, number of internal nodes (non-leaf nodes) and number of leaves respectively. Note that the height of a tree with single node is 1 (not zero). Using structural induction, prove the following: (a) For every Full Binary Tree T, n(T) greaterthanorequalto h(T). (b) For every Full Binary Tree T, i(T)...
Give an equation to calculate the minimum number of nodes in a complete binary tree of height h. This means that every height 1,..,h-1 is completely full.
2. A regular binary tree is a binary tree whose internal nodes all have two subtrees (left and right). In other words, all their nodes have either zero subtrees (in which case they are leaves) or two subtrees (in which case they are internal nodes). Suppose that you have a boolean function that tells you, for each node of the tree, whether it is a leaf or not (call it: leaf(n), for node n). a) Write a recursive function that...