Question: Can anyone help me to write this function? Write a C++ function that returns True if two trees have the same values (they are made

Can anyone help me to write this function?

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.

Plz using the function called

bool sameValueTree(TreeNode *node1, TreeNode *node2, int *& array1, int *& array2 )

And int sizeTree(TreeNode * node) can be a helper function. Just need to write these two function. Don't care about main or other functions

And

int index1 = -1; // index to access array1

int index2 = -1; // index to access array2

int treeSize = -1; // once you find the size of the 2 BSTs assign it to this variable

bool isEqual = true; // change this value accordingly and return it from sameValueTree() were global variables which are already initialized.

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!