Question: STRICTLY USE THE GIVEN FUNCTIONS IN THE TABLE. Implement the union function of the class Tree as given below functions only. This code should implement

STRICTLY USE THE GIVEN FUNCTIONS IN THE TABLE. Implement the union function of the class Tree as given below functions only. This code should implement the structural union of two binary trees. For example, consider the two trees, Tree A and Tree B, given below. Here the union of Tree A and Tree B is given by Tree C. Tree C has the combined structure of the two trees and the node values are the sum of values of the nodes of the two trees. A NULL node can be considered to contain zero value. (Here TREE C has only those nodes which are present in Tree A or Tree B) 1 1 2 2 3 3 5 4 9 1 16 8 9 8 7 9 9 Tree A class Node { Node *LeftChild; Node *RightChild; int Data; friend class Tree; }; Tree B Tree C (union of Tree A and Tree B) class Tree { public: Tree(); //implemented -Tree(); //implemented Tree(const Tree &T); //implemented const Tree & operator = (const Tree &rhs); Tree Union(const Tree &T); Il you have to implement with this function only private: Node *root; So, e.g., Tree C would be returned by the following call: TreeC = TreeB.union(TreeA)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
