Question: Write a C++ function TreeNode* copy_tree(TreeNode* T) that returns a copy of binary tree T Write a C++ function that returns a new binary tree

Write a C++ function TreeNode* copy_tree(TreeNode* T) that returns a copy of binary tree T Write a C++ function 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 T_1 and T_2 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
Get step-by-step solutions from verified subject matter experts
