GATE 2014 (Session 3)
65 questions
MCQ 47 · NAT 181-mark 30 · 2-mark 35
Questions 46–50 of 65
Consider the following languages over the alphabet :
Here is the reverse of the string w. Which of these languages are deterministic Context-free languages?
Here is the reverse of the string w. Which of these languages are deterministic Context-free languages?
Answer: (C)
Let us check each language:
- : the PDA pushes the 0s and pops one for each 1 it is a DCFL.
- : the symbol c shows the middle, so the PDA knows when to begin popping it is a DCFL.
- : the PDA has to guess where the middle is it is a CFL but not a DCFL.
Answer: Only L1 and L2
- : the PDA pushes the 0s and pops one for each 1 it is a DCFL.
- : the symbol c shows the middle, so the PDA knows when to begin popping it is a DCFL.
- : the PDA has to guess where the middle is it is a CFL but not a DCFL.
Answer: Only L1 and L2
Suppose you want to move from 0 to 100 on the number line. In each step, you either move right by a unit distance or you take a shortcut. A shortcut is simply a pre-specified pair of integers i,j with . Given a shortcut i, j if you are at position i on the number line, you may directly move to j. Suppose T(k) denotes the smallest number of steps needed to move from k to 100. suppose further that there is at most 1 shortcut involving any number, and in particular from 9 there is a shortcut to 15. Let y and z be such that T(9) = 1 + min(T(y), T(z)). Then the value of the product yz is_______.
Answer: 150
At 9, there are two choices: move one step right to 10, or use the shortcut to 15.
Recurrence: so y = 10 and z = 15
The product is yz = 150
Answer: 150
Recurrence: so y = 10 and z = 15
The product is yz = 150
Answer: 150
Consider the decision problem 2CNFSAT defined as follows:
For example, is a Boolean formula and it is in 2CNFSAT.
The decision problem 2CNFSAT is
For example, is a Boolean formula and it is in 2CNFSAT.
The decision problem 2CNFSAT is
Answer: (B)
Each clause is equivalent to the two implications and . Build a directed graph with one node per literal and these implications as edges.
The formula is unsatisfiable exactly when, for some variable x, there is a path from x to and a path from to x. These are reachability checks, done in polynomial (even linear) time.
So 2CNFSAT is in P.
(C) is false: is unsatisfiable. (D) cannot hold, since 2CNFSAT is in NP, so NP-hard would make it NP-complete. (A) is not known to be true; it would imply P = NP.
Answer: (B)
The formula is unsatisfiable exactly when, for some variable x, there is a path from x to and a path from to x. These are reachability checks, done in polynomial (even linear) time.
So 2CNFSAT is in P.
(C) is false: is unsatisfiable. (D) cannot hold, since 2CNFSAT is in NP, so NP-hard would make it NP-complete. (A) is not known to be true; it would imply P = NP.
Answer: (B)
Suppose we have a balanced binary search tree T holding n numbers. We are given two numbers L and H and wish to sum up all the numbers in T that lie between L and H. Suppose there are m such numbers in T. If the tightest upper bound on the time to compute the sum is , the value of a + 10b + 100c + 1000d is _______.
Answer: 110
Search for L in the balanced BST. This takes . Then do an in-order walk over the m values up to H. This takes O(m).
Total time = a = 0, b = 1, c = 1, d = 0
a + 10b + 100c + 1000d = 0 + 10 + 100 + 0 = 110
Answer: 110
Total time = a = 0, b = 1, c = 1, d = 0
a + 10b + 100c + 1000d = 0 + 10 + 100 + 0 = 110
Answer: 110
Consider a hash table with 100 slots. Collisions are resolved using chaining. Assuming simple uniform hashing, what is the probability that the first 3 slots are unfilled after the first 3 insertions?
Answer: (A)
In chaining, every key goes to any one of the 100 slots, and each key is independent of the others. So the probability that a key does not land in the first 3 slots is 97/100.
For 3 insertions, the probability is:
Answer: (97 97 97) /
For 3 insertions, the probability is:
Answer: (97 97 97) /