Consider the following C code: int foo (Struct Binary Tree Node * root 1,…
Consider the following C code:
int foo (Struct Binary Tree Node * root 1, Struct Binary Tree Node * root 2)
{
if (root 1 == NULL && root 2 == NULL) return 1;
if (root 1 == NULL || root 2 == NULL) return 0;
if (root 1 -> data != root 2 -> data) return 0;
else return foo (root 1 -> left, root 2 -> right) && foo (root 1 -> right, root 2 -> left);
}
The root node of two Binary trees are passed as an argument to the given code. The code returns 1 if:
- A.
Both the trees are having the same height if height is defined as the distance from root to the farthest leaf node.
- B.
Both the trees are Binary Search Trees.
- C.
Both the trees are mirror images of each other.
- D.
Both the trees have an equal number of nodes.
Attempted by 342 students.
Sign up free to check your answer
Sign up freeLoading lesson…

