GATE 2004
199 questions
MCQ 1991-mark 199
Questions 121–125 of 199
Which one of the following regular expressions is NOT equivalent to the regular expression
Answer: (C)
(A) contains the strings , and , and it is a set of strings over . So it equals .
(B) also contains , , (take two of the three stars empty). So it equals .
(D) contains , (from ) and (from ). So it equals .
(C) . Every string in it is built only from the blocks and . The string is in but cannot be built from these blocks, so (C) is not equivalent.
Answer: (C)
(B) also contains , , (take two of the three stars empty). So it equals .
(D) contains , (from ) and (from ). So it equals .
(C) . Every string in it is built only from the blocks and . The string is in but cannot be built from these blocks, so (C) is not equivalent.
Answer: (C)
The following finite state machine accepts all those binary strings in which the number of 1's and 0's are respectively.
Answer: (A)
The 6 states form 2 rows by 3 columns.
Columns, left to right, count the 1's mod 3: reading a 1 moves one step right, and the third 1 from the right column goes back to the left. Reading a 0 does not change the column.
Rows count the 0's mod 2: reading a 0 switches between the top row (even number of 0's) and the bottom row (odd number of 0's). Reading a 1 does not change the row.
The only accepting state is the start state, at the top left: number of 1's and number of 0's even (divisible by 2).
Check with strings: is accepted, so the 1's need not be even; this rules out (C) and (D), which need an even count of 1's and an odd or 3-divisible count of 0's. The empty string is accepted, with zero 1's and zero 0's; zero is not odd, so (B) and (C) are wrong. is accepted, so 0's need not be divisible by 3.
Answer: (A)
Columns, left to right, count the 1's mod 3: reading a 1 moves one step right, and the third 1 from the right column goes back to the left. Reading a 0 does not change the column.
Rows count the 0's mod 2: reading a 0 switches between the top row (even number of 0's) and the bottom row (odd number of 0's). Reading a 1 does not change the row.
The only accepting state is the start state, at the top left: number of 1's and number of 0's even (divisible by 2).
Check with strings: is accepted, so the 1's need not be even; this rules out (C) and (D), which need an even count of 1's and an odd or 3-divisible count of 0's. The empty string is accepted, with zero 1's and zero 0's; zero is not odd, so (B) and (C) are wrong. is accepted, so 0's need not be divisible by 3.
Answer: (A)
Consider the following grammar G:
Let Na(w) and Nb(w) denote the number of a's and b's in a string w respectively.
The language generated by G is
S → bS | aA | b
A → bA | aB
B → bB | aS | aLet Na(w) and Nb(w) denote the number of a's and b's in a string w respectively.
The language generated by G is
Answer: (C)
Read the non-terminals as states that track the number of 's read so far, modulo 3:
: count , : count , : count .
Each keeps the state (, , ). Each moves . The only ways to stop are and , and both end back in state . So a string is generated exactly when it is non-empty and its number of 's is a multiple of 3.
Check: comes from . comes from .
The string has , so it is not in (A), and is not a multiple of 3, so it is not in (D). The string has , so it is not in (B).
Answer: (C)
: count , : count , : count .
Each keeps the state (, , ). Each moves . The only ways to stop are and , and both end back in state . So a string is generated exactly when it is non-empty and its number of 's is a multiple of 3.
Check: comes from . comes from .
The string has , so it is not in (A), and is not a multiple of 3, so it is not in (D). The string has , so it is not in (B).
Answer: (C)
Let be a finite state automaton, where
A grammar to generate the language accepted by M can be specified as
Which one of the following set of rules will make L(G) = L(M) ?
A grammar to generate the language accepted by M can be specified as
Which one of the following set of rules will make L(G) = L(M) ?
Answer: (B)
Transition: Rule:
Transition: Rule:
Transition: Rule:
Transition: Rule:
State is the final state, so add the rule
Correct Answer:
Transition: Rule:
Transition: Rule:
Transition: Rule:
State is the final state, so add the rule
Correct Answer:
Which one of the following statements is FALSE?
Answer: (C)
(A) True: there are inherently ambiguous context-free languages, for which every context-free grammar is ambiguous.
(B) True: this is what unambiguous means; each string generated has exactly one parse tree.
(C) False: a non-deterministic PDA accepts more languages than a deterministic one. For example, is accepted by an NPDA but by no DPDA.
(D) True: a finite language is always regular.
Answer: (C)
(B) True: this is what unambiguous means; each string generated has exactly one parse tree.
(C) False: a non-deterministic PDA accepts more languages than a deterministic one. For example, is accepted by an NPDA but by no DPDA.
(D) True: a finite language is always regular.
Answer: (C)