Question 1 |

Consider the C function foo and the binary tree shown.

When foo is called with a pointer to the root node of the given binary tree, what will it print?

```
typedef struct node {
int val;
struct node *left, *right;
} node;
int foo(node *p) {
int retval;
if (p == NULL)
return 0;
else {
retval = p->val + foo(p->left) + foo(p->right);
printf("%d ", retval);
return retval;
}
}
```

When foo is called with a pointer to the root node of the given binary tree, what will it print?

3 8 5 13 11 10 | |

3 5 8 10 11 13 | |

3 8 16 13 24 50 | |

3 16 8 50 24 13 |

Question 1 Explanation:

Question 2 |

Consider a complete binary tree with 7 nodes. Let A denote the set of first 3 elements obtained by performing Breadth-First Search (BFS) starting from the root. Let B denote the set of first 3 elements obtained by performing Depth-First Search (DFS) starting from the root.

The value of |A-B| is _____________

The value of |A-B| is _____________

3 | |

4 | |

1 | |

2 |

Question 2 Explanation:

Question 3 |

The post-order traversal of binary tree is ACEDBHIGF. The pre-order traversal is

A B C D E F G H I | |

F B A D C E G I H | |

F A B C D E G H I | |

A B D C E F G I H |

Question 3 Explanation:

Question 4 |

Let T be a full binary tree with 8 leaves. (A full binary tree has every level full.) Suppose two leaves a and b of T are chosen uniformly and independently at random. The expected value of the distance between a and b in T (i.e., the number of edges in the unique path between a and b) is (rounded off to 2 decimal places) ___________ .

2.5 | |

4.25 | |

6.5 | |

3.75 |

Question 4 Explanation:

Question 5 |

Which traversals of Tree-1 and Tree-2, respectively, will produce the same sequence?

Preorder, postorder | |

Postorder, inorder | |

Postorder, preorder | |

None of these |

Question 5 Explanation:

There are 5 questions to complete.

In Question no 8.

Sir please correct option no C)

to

-+1*76^2-5*43

Thank You Abhishek Chavle,

We have updated the answer.

Question no 47

Options A , C , D are correct

Thank You Abhishek Chavle,

We have updated the answer.

In question no. 41

only B option is correct.