Given two binary trees, write a compare function to check if they are equal or not. Being equal means that they have the same value and same structure.
Click for Solution

  • Warning: Illegal string offset 'name' in /home/prepdo6/gpl4you/discussquessub.php on line 681
    A int compare_tree(Node * root1,Node *root2) { if(root1=root2==null) return 1; else if(root1==null && root2!=null)return 0; else if(root2==null && root1!=null)return 0; else if(root1.data==root2.data && compare_tree(root1.left,root2.left) && compare_tree(root1.right&&root2.right)))) return 1; else return 0; }

[Insert Code]