Question 1
Consider the following grammars. Names representing terminals have been specified in capital letters.
G1 : stmnt -> WHILE (expr) stmnt
stmnt -> OTHER
expr -> ID
G2 : stmnt -> WHILE (expr) stmnt
stmnt -> OTHER
expr -> expr + expr
expr -> expr * expr
expr -> ID
Which one of the following statements is true?
[GATE || CS || PYQ || 2007]
G1 is context-free but not regular and G2 is regular.
G2 is context-free but not regular and G1 is regular
Both G1 and G2 are regular
Both G1 and G2 are context-free but neither of them is regular
Question 2
Let πΊ1, πΊ2 be Context Free Grammars (CFGs) and π
be a regular expression. For a grammar πΊ, let πΏ(πΊ) denote the language generated by πΊ.
Which ONE among the following questions is decidable?
[GATE 2025||SET-2 MCQ|| 1-mark]
Is πΏ(πΊ1 ) = πΏ(πΊ2 )?
Is πΏ(πΊ1 ) β© πΏ(πΊ2 ) = β ?
Is πΏ(πΊ1 ) = πΏ(π )?
Is πΏ(πΊ1 ) = β ?
Question 3
Consider two grammars πΊ1 and πΊ2 with the production rules given below:
πΊ1: π β ππ πΈ π‘βππ π | ππ πΈ π‘βππ π πππ π π | π
πΈ β π
πΊ2: π β ππ πΈ π‘βππ π | π
π β ππ πΈ π‘βππ π πππ π π | π
πΈ β π
where ππ,π‘βππ,πππ π, π, π, π are the terminals.
Which of the following option(s) is/are CORRECT?
[GATE 2025 ||SET-2 MSQ|| 2-mark]
πΊ1 is not πΏπΏ(1) and πΊ2 is πΏπΏ(1).
πΊ1 is πΏπΏ(1) and πΊ2 is not πΏπΏ(1).
πΊ1 and πΊ2 are not πΏπΏ(1).
πΊ1 and πΊ2 are ambiguous.
Question 4
Consider a context-free grammar πΊ with the following 3 rules.
π β ππ, π β ππππ, π β π
Let π€ β πΏ(πΊ). Let ππ (π€), ππ (π€), ππ (π€) denote the number of times π, π, π occur in π€, respectively. Which of the following statements is/are TRUE?
[GATE 2024||SET-2 MSQ|| 1-mark]
ππ(π€) > ππ(π€)
ππ(π€) > ππ (π€) β 2
ππ(π€) = ππ(π€) + 1
ππ(π€) = ππ(π€) β 2
Question 5
Consider the following languages:
L1 = {ww | w β {a, b}* }
L2 = {anbncm | m, nβ₯ 0}
L3 = {ambncn | m, nβ₯ 0}
Which of the following statements is/are FALSE?
[GATE 2022|| MSQ|| 1-mark]
L1 is not context-free but L2 and L3 are deterministic context-free.
Neither L1 nor L2 is context-free.
L2, L3, and L2 β© L3 all are context-free.
Neither L1 nor its complement is context-free.
Question 6
Let L be a context-free language and M a regular language. Then the language is L β© M
[GATE || CS || PYQ || 2006 ||]
always regular
never regular
always a deterministic context-free language
always a context-free language
Question 7
Consider the languages:
Which one of the following is TRUE?
[GATE || CS || PYQ || 2005]
L1 is a deterministic CFL
L2 is a deterministic CFL
L3 is a CFL, but not a deterministic CFL
L3 is a deterministic CFL
Question 8
Let
L1 = {0n+m1n0m | n, m >= 0},
L2 = {0n+m1n+m0m | n, m >= 0} and
L3 = {0n+m1n+m0n+m | n, m >= 0}.
Which of these languages are NOT context free?
[GATE || CS || PYQ || 2006]
L1 only
L3 only
L1 and L2
L2 and L3
Question 9
S-> aSa | bSb | a | b
The language generated by the above grammar over the alphabet is the set of:
[GATE || CS || PYQ || 2009]
all palindromes
all odd length palindromes
strings that begin and end with the same symbol
all even length palindromes
Question 10
In the context-free grammar below, is the start symbol, and are terminals, and denotes the empty string.
S ->aSAb | β
A-> bA | β
The grammar generates the language
[GATE || CS || PYQ || 2006]
((a+b)*b)
{ ambn β£ mβ€n }
(ambn | m=n }
a*b*
There are 52 questions to complete.