GATE 2002
56 questions
MCQ 561-mark 56
Questions 36–40 of 56
Answer: (D)
Total nodes:
A tree with nodes has edges. Only internal nodes produce edges, each, so
From (2), . Put this in (1):
Answer: (D)
Answer: (D)
Let a node have nodes in its left sub-tree and in its right. The rule gives (and the same the other way round). So the bigger sub-tree has at most twice as many nodes as the smaller one.
The tallest tree is made when every node sends as many nodes as possible to one side. Say . Then , so and . The bigger sub-tree holds at most about of the nodes.
The longest path always goes into the bigger sub-tree, so with height counted in nodes:
Unroll it: after steps the size is about and the height is . The size reaches 1 when , that is , so .
So the maximum height is best described by . Option (B), , would need the bigger side to hold of the nodes, which the rule does not allow.
Answer: (D)
Procedure A(n)
If n 2 return (1) else return (A());
is best discribed by
Answer: (C)
The running time is the number of recursive calls. This equals the number of times we can take the square root of n again and again, until n becomes .
So,
Answer : Option C
Answer: (B)
Use case 1 of the Master theorem with and , since for some .
So .
This is not , so (A) is out, and (B) is the only option of order .
We can also solve it exactly by unrolling:
The recursion depth is . The bracket is a GP with first term and ratio , and it has terms, so its sum is . With :
Check: gives and .
Answer: (B)
Answer: (B)
The automaton only needs to know the length of the input mod 3. It has three states: (start and only final state), and . Every symbol moves it around the cycle . So 3 states are enough.
Fewer is not possible. Two inputs whose lengths differ mod 3 can be told apart by a suitable suffix. If the lengths are , append any string of length . The first total length is divisible by 3 and is accepted, and the second is not. So the three length classes need three different states.
Answer: (B)