Write an efficient algorithm to check given two tree are Identical. In this post given a iterative solution using of stack.
Following conditions of identical tree.
1) number of nodes are equal in both given tree.
2) visit both tree every node similar manner(inorder , peroder, post order choose any one). there parent node values are same.
if not equal that means there are not identical of tree.
Function to check identical of two binary tree.
Structure of given tree.
Program for check two given tree are identical. Time complexity O(n).
Execution Process Try it Yourself