Question: 5. Write a C++ function TreeNode* expand_leaf (TreeNode* node, ItemType x, ItemType y) that returns a new binary tree that is identical to the

 5. Write a C++ function TreeNode* expand_leaf (TreeNode* node, ItemType x, ItemType 

5. Write a C++ function 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 I 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. 5 1 3 5 1 3 9 12

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 Programming Questions!