Write a function that checks whether tow binary trees are quasi-isomorphic.

Two binary trees rare isomorphic if they have the same structure. The values of the nodes does not affect whether two trees are isomorphic or not.

Two binary trees B and C are quasi-isomorphic if B can be transformed into C by swapping the left and right children of some of the nodes of B. Data in the nodes are not important in determining quasi-isomorphism; only the shape is important. 


Difficulty level
This exercise is mostly suitable for students
int quasiIsomorphic(Btree B, Btree C)
{
    if(!B && !C) return 1;
    if(!B && C || B && !C) return 0;
    return quasiIsomorphic(B->left, C->left) && quasiIsomorphic(B->right, C->right) || 
		quasiIsomorphic(B->left, C->right) && quasiIsomorphic(B->right, C->left) ;
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Derivative and second derivative