How to Check If Two Binary Trees are Identical.
Given two binary trees, write a code to check if they are the same or not.
Two binary trees are considered the same if they are structurally identical and the nodes have the same value.
For example: (Check the image)
Example 1: true
In this first example, Both the trees are same. They have the same structure as well as their node values are same.
Example 2: false
In the second example, Both the trees are structurally same but the value of left children of tree A is not equal to tree B.
Example 3: false
Both the trees are structurally not identical.