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:

  1. A.

    Both the trees are having the same height if height is defined as the distance from root to the farthest leaf node.

  2. B.

    Both the trees are Binary Search Trees.

  3. C.

    Both the trees are mirror images of each other.

  4. D.

    Both the trees have an equal number of nodes.

Attempted by 342 students.

Sign up free to check your answer

Sign up free

Explore the full course: Isro

Loading lesson…