Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions