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 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
Get step-by-step solutions from verified subject matter experts
