Date : 18 December 2020

Two numbers are in the ratio 7:10. If the larger number is 140, what is the smaller number?

94

96

98

92

**Ans:** 98

A process executes the code

fork ();fork ();fork ();

The total number of child processes created is

3

4

7

8

**Ans** (C) 7

Let us put some label names for the three lines

fork (); // Line 1

fork (); // Line 2

fork (); // Line 3

`We can also use a direct formula to get the number of child processes. With n fork statements, there are always 2^n ā 1 child processes.`

ā

There is a computer network connected in a Binary tree-like structure. You as a network engineer want to connect any of the leaf computers with all other leaf computers with wlan wires. It is not possible to connect two leaf computer if the difference between their depth from the root is greater than 1. You need to tell your Boss whether it is possible to connect any of the leaf computers with all other leaf computers.

**Note that, if the network contains only one leaf computer then you don't need to connect it. That is, the output will be "YES"**

Input: The First line of input contains the number of test cases T. For each test case, there will be only a single line of input which is a string representing the network as described below:

The values in the string are in the order of level order traversal of the network where, numbers denote computers, and a character āNā denotes NULL child.

**Example: **

Input:21 2 3 4 5 6 71 2 3 4 5 N N 6āOutput:YesNo

ā

**Explanation**:

Test Case 1:ā1/ \2 3/ \ / \4 5 6 7āAll leaf computers are at same level.āāTest Case 2:ā1/ \2 3/ \4 5Leaf computers are 3, 5 & 6 andtheir depths are 2, 3 and 4 respectively and (4-2)=2 > 1ā

vector<int>v;void find(Node* root,int depth){if(!root) return;if(!root->left && !root->right){v.push_back(depth);return;}find(root->left,depth+1);find(root->right,depth+1);}bool isPossible(Node *root) {āv.clear();find(root,0);sort(v.begin(),v.end());if(abs(v[0]-v[v.size()-1])>1) return false;return true;}

ā