GATE 2010
82 questions
MCQ 821-mark 39 · 2-mark 43
Questions 36–40 of 82
Consider a complete undirected graph with vertex set {0, 1, 2, 3, 4}. Entry in the matrix W below is the weight of the edge {i, j}.
What is the minimum possible weight of a spanning tree T in this graph such that vertex 0 is a leaf node in the tree T?
What is the minimum possible weight of a spanning tree T in this graph such that vertex 0 is a leaf node in the tree T?
Answer: (D)
First find the MST on the vertices {1, 2, 3, 4}. After that, add vertex 0 as a leaf.
MST of {1, 2, 3, 4}: edges 3-4 (2), 2-4 (3) and 1-3 (4). Their sum is 9.
Now join 0 using its cheapest edge. This is 0-1 or 0-3, with weight 1.
Total = 9 + 1 = 10
Answer: 10
MST of {1, 2, 3, 4}: edges 3-4 (2), 2-4 (3) and 1-3 (4). Their sum is 9.
Now join 0 using its cheapest edge. This is 0-1 or 0-3, with weight 1.
Total = 9 + 1 = 10
Answer: 10
Consider a complete undirected graph with vertex set {0, 1, 2, 3, 4}. Entry in the matrix W below is the weight of the edge {i, j}.
What is the minimum possible weight of a path P from vertex 1 to vertex 2 in this graph such that P contains at most 3 edges?
What is the minimum possible weight of a path P from vertex 1 to vertex 2 in this graph such that P contains at most 3 edges?
Answer: (B)
Weights: .
All paths from 1 to 2 with at most 3 edges:
- 1 edge: 1-2 = 12
- 2 edges: 1-0-2 = 1+8 = 9, 1-3-2 = 4+7 = 11, 1-4-2 = 9+3 = 12
- 3 edges: 1-0-3-2 = 1+1+7 = 9, 1-0-4-2 = 1+4+3 = 8, 1-3-0-2 = 4+1+8 = 13, 1-3-4-2 = 4+2+3 = 9, 1-4-0-2 = 9+4+8 = 21, 1-4-3-2 = 9+2+7 = 18
The minimum is 8. (The cheapest path overall, 1-0-3-4-2 = 1+1+2+3 = 7, has 4 edges, so it is not allowed.)
Answer: (B)
All paths from 1 to 2 with at most 3 edges:
- 1 edge: 1-2 = 12
- 2 edges: 1-0-2 = 1+8 = 9, 1-3-2 = 4+7 = 11, 1-4-2 = 9+3 = 12
- 3 edges: 1-0-3-2 = 1+1+7 = 9, 1-0-4-2 = 1+4+3 = 8, 1-3-0-2 = 4+1+8 = 13, 1-3-4-2 = 4+2+3 = 9, 1-4-0-2 = 9+4+8 = 21, 1-4-3-2 = 9+2+7 = 18
The minimum is 8. (The cheapest path overall, 1-0-3-4-2 = 1+1+2+3 = 7, has 4 edges, so it is not allowed.)
Answer: (B)
Let L = {w (0 + 1)*|w has even number of 1s}, i.e. L is the set of all bit strings with even number of 1s. Which one of the regular expressions below represents L?
Answer: (B)
In , the part takes the leading 0s. Each group holds exactly two 1s with any number of 0s after each. So every string it makes has an even number of 1s, and any string with an even number of 1s can be cut into leading 0s and such groups. So (B) represents L.
Why the others fail:
- (A) makes only strings that are empty or end in 1, so it cannot make "0" or "110".
- (C) can put 0s only inside a group or at the two ends, so it cannot make "11011" (four 1s).
- (D) needs at least two 1s, so it cannot make "0" or the empty string.
Answer: (B)
Why the others fail:
- (A) makes only strings that are empty or end in 1, so it cannot make "0" or "110".
- (C) can put 0s only inside a group or at the two ends, so it cannot make "11011" (four 1s).
- (D) needs at least two 1s, so it cannot make "0" or the empty string.
Answer: (B)
Let w be any string of length n in {0, 1}*. Let L be the set of all substrings of w. What is the minimum number of states in a non-deterministic finite automaton that accepts L?
Answer: (C)
Enough: make a chain of states that spells out w, one symbol per step. Add moves from to every other state, so the automaton can start anywhere, and let every state accept. Starting at and stopping at reads exactly a substring of w. This needs n + 1 states.
Needed: the strings in L have length at most n, so L is finite. In an NFA for a finite language, a shortest accepting path for w cannot repeat a state. A repeat with a non-empty loop could be pumped to accept longer and longer strings, and a loop that reads nothing can be cut out. The path for w reads n symbols, so it goes through at least n + 1 different states.
So the minimum is n + 1.
Answer: (C)
Needed: the strings in L have length at most n, so L is finite. In an NFA for a finite language, a shortest accepting path for w cannot repeat a state. A repeat with a non-empty loop could be pumped to accept longer and longer strings, and a loop that reads nothing can be cut out. The path for w reads n symbols, so it goes through at least n + 1 different states.
So the minimum is n + 1.
Answer: (C)
Consider the languages
.
.
.
Which one of the following statements is true?
.
.
.
Which one of the following statements is true?
Answer: (D)
A PDA has one stack, so it can compare one count with another (or with twice another). Each language below has a context-free grammar.
- L1 (): this is or . For : , . For : , with the same T. The union of two CFLs is a CFL.
- L2 (): . This is the standard CFL: push a symbol for each 0, pop one for each 1.
- L3 (): . As a PDA: push one symbol for each 0, pop two for each 1, and accept when exactly one symbol is left.
- L4 (): this is or . For : , . For : , with the same U. This gives or followed by at least one extra 1. The union of two CFLs is a CFL.
So all four languages are context-free. Options (A), (B) and (C) each leave out at least one of them.
Answer: (D)
- L1 (): this is or . For : , . For : , with the same T. The union of two CFLs is a CFL.
- L2 (): . This is the standard CFL: push a symbol for each 0, pop one for each 1.
- L3 (): . As a PDA: push one symbol for each 0, pop two for each 1, and accept when exactly one symbol is left.
- L4 (): this is or . For : , . For : , with the same U. This gives or followed by at least one extra 1. The union of two CFLs is a CFL.
So all four languages are context-free. Options (A), (B) and (C) each leave out at least one of them.
Answer: (D)