Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions

Question

Gather internal and external data and prepare financial statements.

Answered: 1 week ago

Question

What is Working Capital ? Explain its types.

Answered: 1 week ago