Question: Write a C++ function that returns True if two trees have the same values (they are made of nodes with the same values.) It should

 Write a C++ function that returns True if two trees have

the same values (they are made of nodes with the same values.)

It should return True if the trees have te same values or

Write a C++ function that returns True if two trees have the same values (they are made of nodes with the same values.) It should return True if the trees have te same values or False otherwise. The function takes four arguments: treenode of tree1, treenode of tree2, and two arrays. Note that two trees can have the same values but not have the same structure. To successfully code this function up you will have to populate two arrays in ascending order with the values you find when traversing the two trees. For example: if samevalueTree0 is called on the following two trees: It should return True. However, if samevalueTree0 is called on the following two trees: It should return False. Few notes to help you out: 1) Function header should be: bool samevalueTree(TreeNode *node1, TreeNode *node2, int & array 1, int *& array2)

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