GATE 2006
191 questions
MCQ 1911-mark 191
Questions 136–140 of 191
Let L1 be regular language, L2 be a deterministic context-free language and L3 a recursively enumerable, but not recursive, language. Which one of the following statements is false?
Answer: (B)
is regular and is a DCFL, so both are recursive; is recursively enumerable (RE) but not recursive.
(A) True: the intersection of a DCFL with a regular language is a DCFL.
(B) False: the intersection of a recursive language and an RE language is RE, but it need not be recursive. For example, if , then , which is not recursive.
(C) True: is regular, so it is a CFL, and every DCFL is a CFL. CFLs are closed under union.
(D) True: , and are all RE, and RE languages are closed under intersection.
Answer: (B)
(A) True: the intersection of a DCFL with a regular language is a DCFL.
(B) False: the intersection of a recursive language and an RE language is RE, but it need not be recursive. For example, if , then , which is not recursive.
(C) True: is regular, so it is a CFL, and every DCFL is a CFL. CFLs are closed under union.
(D) True: , and are all RE, and RE languages are closed under intersection.
Answer: (B)
For , let d(s) denote the decimal value of s (e.g. d(101)=5).
Let L={s (0+1)*| d(s) mod 5=2 and d(s) mod 74}
Which one of the following statements is true?
Let L={s (0+1)*| d(s) mod 5=2 and d(s) mod 74}
Which one of the following statements is true?
Answer: (D)
Reading a new bit changes the value of the string to . So a DFA that keeps only the remainder modulo can move from state to state on bit .
The language is regular. Its DFA has states , start state , and the only final state is .
In the same way, is also regular. Its DFA has states with start state . All of them are final states except .
So , which is of the given problem, is also regular, because regular languages are closed under intersection (a product DFA with states accepts it).
A regular language is also context-free and recursive, so (A), (B) and (C) are false.
Answer: (D)
The language is regular. Its DFA has states , start state , and the only final state is .
In the same way, is also regular. Its DFA has states with start state . All of them are final states except .
So , which is of the given problem, is also regular, because regular languages are closed under intersection (a product DFA with states accepts it).
A regular language is also context-free and recursive, so (A), (B) and (C) are false.
Answer: (D)
The grammar
SAC|CB
CaCb|
AaA|a
BBb|b
generates the language , what is the length of the derivation (number of steps starting from S) to generate the string with ?
SAC|CB
CaCb|
AaA|a
BBb|b
generates the language , what is the length of the derivation (number of steps starting from S) to generate the string with ?
Answer: (A)
The string is with , so either or .
Case I, : write the string as , where .
- : 1 step.
- gives in steps (for example is 1 step, is 2 steps).
- gives in steps ( uses of and one ).
Total: .
Case II, : write the string as , where .
- : 1 step.
- gives in steps.
- gives in steps.
Total: .
In both cases the length is .
Answer: (A)
Case I, : write the string as , where .
- : 1 step.
- gives in steps (for example is 1 step, is 2 steps).
- gives in steps ( uses of and one ).
Total: .
Case II, : write the string as , where .
- : 1 step.
- gives in steps.
- gives in steps.
Total: .
In both cases the length is .
Answer: (A)
Which one of the following grammars generates the language
(A) (B) S → aS | Sb | a | b
S → AC | CB
C → aCb | a | b
A → aA | ∈
B → Bb | ∈
(C) (D)
S → AC | CB S → AC | CB
C → aCb | ∈ C → aCb | ∈
A → aA | ∈ A → aA | a
B → Bb | ∈ B → Bb | bAnswer: (D)
Check each grammar for a string of the form with that it generates (such a string is not in L), and check that D gives all strings with .
Option A. ends with an a or a b, so C gives or . Then can be derived: . It has , so A is wrong.
Option B. can be derived: . So B is wrong.
Option C. C gives (), and A and B can be . So , which has . So C is wrong.
Option D. C gives . A gives (at least one a), so gives , which is with . B gives , so gives , which is with . Together these are exactly the strings with .
Answer: (D)
Option A. ends with an a or a b, so C gives or . Then can be derived: . It has , so A is wrong.
Option B. can be derived: . So B is wrong.
Option C. C gives (), and A and B can be . So , which has . So C is wrong.
Option D. C gives . A gives (at least one a), so gives , which is with . B gives , so gives , which is with . Together these are exactly the strings with .
Answer: (D)
Consider the following grammar
S FR
R * S |
F id
In the predictive parser table, M, of the grammar the entries M[S, id] and M[R,$] respectively
S FR
R * S |
F id
In the predictive parser table, M, of the grammar the entries M[S, id] and M[R,$] respectively
Answer: (A)
FIRST(S) = FIRST(F) = {id}, so goes in M[S, id].
because S is the start symbol and S appears nowhere else on a right side except at the end of . R ends the production , so FOLLOW(R) contains FOLLOW(S), and .
Rule: for a production , put it in M[A, t] for every t in FOLLOW(A). So goes in M[R, ]. The production only goes under the input *, so it is not in M[R, ].
and .
Answer: (A)
because S is the start symbol and S appears nowhere else on a right side except at the end of . R ends the production , so FOLLOW(R) contains FOLLOW(S), and .
Rule: for a production , put it in M[A, t] for every t in FOLLOW(A). So goes in M[R, ]. The production only goes under the input *, so it is not in M[R, ].
and .
Answer: (A)