Preview:
class Solution
{
    public:
    //Function to check if two trees are identical.
    bool isIdentical(Node *r1, Node *r2)
    {
        if(r1==NULL && r2==NULL) return 1;
        if(r1!=NULL && r2!=NULL)
        { return
          (r1->data==r2->data 
          && isIdentical(r1->left,r2->left) 
          && isIdentical(r1->right,r2->right));
        }
        return 0;
        //Your Code here
    }
};
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter