Monday, January 16, 2012

Checking two trees are indentical


int identical(node* root1,node *root2)
{
if(!root1 && ! root2)
return 1;
else if((!root1 && root2) || (root1 &&!root2))
return 0;
else
return((root1==root2) && identical(root1->left,root2->left) && identical(root1->right,root2->right));
}

No comments: