IM getting an error . please tell me the correct apporach or my error

@Anchal
Don’t check if(root1->data!=root2->data) as we are only concerned about the structure and not the data. While the data may be different , the two trees are required to have the same structure.

Your code gives a runtime error when the compare function reaches a condition when both root1 and root2 are NULL. You have not employed a check for this condition and your code tries to access the right and left part of NULL trees thus giving you a runtime error. Please correct it.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.