Question: Define the internal path length for a tree as the sum of the depths of all internal nodes, while the external path length is the
Define the internal path length for a tree as the sum of the depths of all internal nodes, while the external path length is the sum of the depths of all leaf nodes in the tree. Prove by induction that if tree T is a full binary tree with n internal nodes, I is T’s internal path length, and E is T’s external path length, then E = I + 2n for n ≥ 0.
Step by Step Solution
3.54 Rating (158 Votes )
There are 3 Steps involved in it
Introduction The internal path length for a tree is the sum of the depths of all internal nodes while the external path length is the sum of the depths of all leaf nodes in the tree In this essay we will prove by induction that if tree T is a full binary tree with n internal nodes I is Ts internal path length and E is Ts external path length then E I 2n for n 0 Base Case Lets start by considering a full binary tree T with 0 internal nodes n 0 In this case there are no internal nodes to sum so the internal path length I is 0 Since a tree with 0 internal nodes must have all its nodes as leaves the external path length E is also 0 According to the formula E I 2n when n 0 E I 20 I Therefore the base case holds true for n 0 Inductive Step Now lets assume that the formula E I 2n holds true for a full binary tree T with n internal nodes We want to prove that the formula also holds for a full binary tree T with n 1 internal nodes Consider a full binary tree T with n 1 internal nodes We can create this tree by adding a new internal node and making it the parent of two new leaf nodes Lets denote the new internal node as x Full Binary Tree with n1 Internal Nodes The external path length E of this new tree T is the sum of the depths of all leaf nodes Since x has two child nodes the depths of these new leaf nodes are n 1 and n 2 The external path length E of T is the sum of the depths of all leaf nodes in T and the depths of the new leaf nodes which is E ET n 1 n 2 The internal path length I of T is the sum of the depths of all internal nodes in T and the depth ... View full answer
Get step-by-step solutions from verified subject matter experts
