Question: TreeNode* expand_leaf(TreeNode* node, ItemType x, ItemType y) that returns a new binary tree that is identical to the binary tree T except that every leaf

 TreeNode* expand_leaf(TreeNode* node, ItemType x, ItemType y) that returns a new

TreeNode* expand_leaf(TreeNode* node, ItemType x, ItemType y) that returns a new binary tree that is identical to the binary tree T except that every leaf in T now has a left child and a right child whose values are equal to x and y, respectively. For example, invoking expand_leaf (T, 9, 12) on the tree on the left produces the tree on the right. Write a C++ function int height (TreeNode* T) that returns the height of the binary tree T. Write a C++ function bool same_tree(TreeNode* T1, TreeNode* T2) that returns true if binary trees T1 and T2 are exactly the same (same values, same structure), and returns false otherwise. You may assume that values of tree_item_type can be compared by means of the == operator

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!