GATE 2014 (Session 1)
65 questions
MCQ 40 · NAT 251-mark 30 · 2-mark 35
Questions 46–50 of 65
Which of the regular expressions given below represent the following DFA?
I) 0*1(1+00*1)*
II) 0*1*1+11*0*1
III) (0+1)*1
I) 0*1(1+00*1)*
II) 0*1*1+11*0*1
III) (0+1)*1
Answer: (B)
Read the DFA: from the start state, 0 stays and 1 goes to the final state. From the final state, 1 stays and 0 goes back to the start. So every 0 leads to the start state and every 1 leads to the final state. The machine is in the final state exactly when the last symbol is 1. It accepts the strings that end with 1.
- III is . This is exactly "ends with 1", so it is true.
- I is . Every string it makes ends in 1. Every string that ends in 1 is made by it: write it as followed by the rest. The rest is cut after each of its 1s into pieces that are either "1" or with , and these are covered by . So I is true.
- II is . The string 0101 ends in 1 so the DFA accepts it, but II cannot make it. The first part has no 0 after a 1, and the second part starts with 1. So II is false.
Answer: (B)
- III is . This is exactly "ends with 1", so it is true.
- I is . Every string it makes ends in 1. Every string that ends in 1 is made by it: write it as followed by the rest. The rest is cut after each of its 1s into pieces that are either "1" or with , and these are covered by . So I is true.
- II is . The string 0101 ends in 1 so the DFA accepts it, but II cannot make it. The first part has no 0 after a 1, and the second part starts with 1. So II is false.
Answer: (B)
There are 5 bags labelled 1 to 5. All the coins in a given bag have the same weight. Some bags have coins of weight 10 gm, others have coins of weight 11 gm. I pick 1, 2, 4, 8, 16 coins respectively from bags 1 to 5. Their total weight comes out to 323 gm. Then the product of the labels of the bags having 11 gm coins is ___.
Answer: 12
Suppose every coin weighs 10 g. Then the total is (1 + 2 + 4 + 8 + 16) 10 = 310 g. The real total is 13 g more. This extra weight comes only from the bags with 11 g coins, and each coin picked from such a bag adds 1 g. So 13 = 1 + 4 + 8 bags 1, 3, 4.
Product of the labels = 1 3 4 = 12
Answer: 12
Product of the labels = 1 3 4 = 12
Answer: 12
Suppose a polynomial time algorithm is discovered that correctly computes the largest clique in a given graph. In this scenario, which one of the following represents the correct Venn diagram of the complexity classes P, NP and NP Complete (NPC)?
Answer: (D)
The decision version of clique (does the graph have a clique of size k?) is NP-complete. An algorithm that finds the largest clique in polynomial time also answers this question in polynomial time.
Every problem in NP reduces in polynomial time to an NP-complete problem, so a polynomial-time algorithm for one of them puts all of NP in P. So P = NP.
Then every problem in P, apart from the two trivial languages (accept nothing, accept everything), is NP-complete: a reduction can simply solve the input itself and output a fixed yes or no instance. Ignoring those two, P = NP = NPC, as drawn in (D).
(A), (B) and (C) each draw NPC as only a small part of the other classes, which cannot happen once P = NP.
Answer: (D)
Every problem in NP reduces in polynomial time to an NP-complete problem, so a polynomial-time algorithm for one of them puts all of NP in P. So P = NP.
Then every problem in P, apart from the two trivial languages (accept nothing, accept everything), is NP-complete: a reduction can simply solve the input itself and output a fixed yes or no instance. Ignoring those two, P = NP = NPC, as drawn in (D).
(A), (B) and (C) each draw NPC as only a small part of the other classes, which cannot happen once P = NP.
Answer: (D)
The minimum number of comparisons required to find the minimum and the maximum of 100 numbers is _________________.
Answer: 147.1 to 148.1
First, group the numbers into pairs and compare each pair. This takes 50 comparisons. Next, find the maximum among the 50 larger numbers, which takes 49 comparisons. Then find the minimum among the 50 smaller numbers, which also takes 49 comparisons.
Total comparisons:
Answer: 148
Total comparisons:
Answer: 148
Consider a hash table with 9 slots. The hash function is h(k)=k mod 9. The collisions are resolved by chaining. The following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33, 12, 17, 10. The maximum, minimum, and average chain lengths in the hash table, respectively, are
Answer: (A)
Find each key's slot using k mod 9: 5 5, 28 1, 19 1, 15 6, 20 2, 33 6, 12 3, 17 8, 10 1.
Chain lengths: slot 1 has 3, slot 6 has 2, slots 2, 3, 5 and 8 have 1 each, and slots 0, 4 and 7 have 0.
The maximum is 3, the minimum is 0, and the average is 9/9 = 1.
Answer: 3, 0, and 1
Chain lengths: slot 1 has 3, slot 6 has 2, slots 2, 3, 5 and 8 have 1 each, and slots 0, 4 and 7 have 0.
The maximum is 3, the minimum is 0, and the average is 9/9 = 1.
Answer: 3, 0, and 1