Algorithm for searching isomorphic nature in binary trees

What will be the algorithm for checking two binary trees that are isomorphic in nature? my code is

boolean isIsomorphic(Root t1 , Root t2){
    if(t1==null || t2==null){
        return false;
    }

    if((t1.value == t2.value) && (isIsomorphic(t1.left,t2.right) && isIsomorphic(t1.right,t2.left))) {
        return true
    }

    return false; 
}
+3
source share
2 answers

The wikipedia article for 'isomorphism' states that β€œif two objects are isomorphic, then any property that is isomorphism conserves, and that applies to one of the objects, also applies to the other.

So your question should indicate if you care about form, data, performance, etc.

If you care about the behavior of the binary tree for the search, your algorithm is incorrect. See What does it mean to be isomorphic for two binary trees?

- , .

, , @amits . , .

, , t1.value == t2.value

+3

: s t , s t s. , .

.

, :

  • , , . , " ISOMORPHIC"
  • .
  • node , .
  • , "NOT ISOMORPHIC".
  • , ISOMORPHIC.
0

All Articles