Context Free Languages questions — page 1 of 2

Q25

GATE CS 2026 CS-1Context Free LanguagesMSQ1 mark
Consider the following grammar where SS is the start symbol, and aa and bb are terminal symbols.

S→aSbS∣bS∣ϵS \to aSbS \mid bS \mid \epsilon

Which of the following statements is/are true?
More than one option can be correct.
Show answer without attempting

Answer: A, B, C

Q52

GATE CS 2026 CS-1Context Free LanguagesMSQ2 marks
Consider the following context-free grammar GG.

S→abaABAbbaS \to abaABAbba
A→aaBBAIn∣bBabaaA \to aaBBAIn \mid bBabaa
B→aBb∣abB \to aBb \mid ab

In the above grammar, SS is the start symbol, aa and bb are terminal symbols, and AA and BB are non-terminal symbols.

Let L(G)L(G) be the language generated by the grammar GG. For a string s∈L(G)s \in L(G), let n1(s)n_1(s) be the number of aa’s in ss and n2(s)n_2(s) be the number of bb’s in ss.

Which of the following statements is/are true?
More than one option can be correct.
Show answer without attempting

Answer: B, D

Q29

GATE CS 2026 CS-2Context Free LanguagesMSQ1 mark
Which of the following grammars is/are ambiguous?
More than one option can be correct.
Show answer without attempting

Answer: B, C

Q48

GATE CS 2026 CS-2Context Free LanguagesMSQ2 marks
Let Σ={a,b,c,d}\Sigma = \{a, b, c, d\} and let L={aibjckdℓ∣i,j,k,ℓ≥0}L = \{a^i b^j c^k d^\ell \mid i, j, k, \ell \ge 0\}.

Which of the following constraints ensure(s) that the language LL is context-free?
More than one option can be correct.
Show answer without attempting

Answer: A, C, D

Q19

GATE CS 2025 CS-1Context Free LanguagesMCQ1 mark−1/3 if wrong
Consider the following context-free grammar GG, where S,AS, A, and BB are the variables (non-terminals), aa and bb are the terminal symbols, SS is the start variable, and the rules of GG are described as:
S→aaB∣AbbS \rightarrow aaB \mid Abb
A→a∣aAA \rightarrow a \mid aA
B→b∣bBB \rightarrow b \mid bB
Which ONE of the languages L(G)L(G) is accepted by GG?
Show answer without attempting

Answer: A

Q45

GATE CS 2025 CS-1Context Free LanguagesMCQ2 marks−2/3 if wrong
Consider the following two languages over the alphabet \{a, b, c\}, where mm and nn are natural numbers.
L1={ambmcm+n∣m,n≥1}L_1 = \{a^mb^mc^{m+n} \mid m, n \ge 1\}
L2={ambncm+n∣m,n≥1}L_2 = \{a^mb^nc^{m+n} \mid m, n \ge 1\}
Which ONE of the following statements is CORRECT?
Show answer without attempting

Answer: C

Q24

GATE CS 2025 CS-2Context Free LanguagesMCQ1 mark−1/3 if wrong
Which ONE of the following languages is accepted by a deterministic pushdown automaton?
Show answer without attempting

Answer: A

Q30

GATE CS 2025 CS-2Context Free LanguagesMSQ1 mark
Consider the two lists List I and List II given below:
List IList II
(i) Context free languages(a) Closed under union
(ii) Recursive languages(b) Not closed under complementation
(iii) Regular languages(c) Closed under intersection
For matching of items in List I with those in List II, which of the following option(s) is/are CORRECT?
More than one option can be correct.
Show answer without attempting

Answer: B, C

Q38

GATE CS 2024 CS-1Context Free LanguagesMCQ2 marks−2/3 if wrong
Consider the following grammar GG, with SS as the start symbol. The grammar GG has three incomplete productions denoted by (1), (2), and (3).
S→daT∣(1)S \to daT \mid (1)
T→aS∣bT∣(2)T \to aS \mid bT \mid (2)
R→(3)∣ϵR \to (3) \mid \epsilon
The set of terminals is {a,b,c,d,f}\{a, b, c, d, f\}. The FIRST and FOLLOW sets of the different non-terminals are as follows.
FIRST(S)={c,d,f},FIRST(T)={a,b,ϵ},FIRST(R)={c,ϵ}\text{FIRST}(S) = \{c, d, f\}, \text{FIRST}(T) = \{a, b, \epsilon\}, \text{FIRST}(R) = \{c, \epsilon\}
FOLLOW(S)=FOLLOW(T)={c,f,$},FOLLOW(R)={f}\text{FOLLOW}(S) = \text{FOLLOW}(T) = \{c, f, \$\}, \text{FOLLOW}(R) = \{f\}
Which one of the following options CORRECTLY fills in the incomplete productions?
Show answer without attempting

Answer: A

Q59

GATE CS 2024 CS-1Context Free LanguagesNAT2 marks
Let G=(V,Σ,S,P)G = (V, \Sigma, S, P) be a context-free grammar in Chomsky Normal Form with Σ={a,b,c}\Sigma = \{a, b, c\} and VV containing 10 variable symbols including the start symbol SS. The string w=a30b30c30w = a^{30}b^{30}c^{30} is derivable from SS. The number of steps (application of rules) in the derivation S→∗wS \to^* w is _________
Show answer without attempting

Answer: 179

Q52

GATE CS 2024 CS-2Context Free LanguagesMSQ2 marks
Consider a context-free grammar GG with the following 3 rules.
S→aSS \to aS, S→aSbSS \to aSbS, S→cS \to c

Let w∈L(G)w \in L(G). Let na(w),nb(w),nc(w)n_a(w), n_b(w), n_c(w) denote the number of times a,b,ca, b, c occur in ww, respectively. Which of the following statements is/are TRUE?
More than one option can be correct.
Show answer without attempting

Answer: B, C

Q39

GATE CS 2023 CSContext Free LanguagesMCQ2 marks−2/3 if wrong
Consider the context-free grammar GG below
<br>S→aSb∣X<br>X→aX∣Xb∣a∣b<br>\begin{align*}<br>S & \to aSb \mid X \\<br>X & \to aX \mid Xb \mid a \mid b<br>\end{align*}
where SS and XX are non-terminals, and aa and bb are terminal symbols. The starting non-terminal is SS.

Which one of the following statements is CORRECT?
Show answer without attempting

Answer: B

Q40

GATE CS 2023 CSContext Free LanguagesMCQ2 marks−2/3 if wrong
Consider the pushdown automaton (PDA) PP below, which runs on the input alphabet {a,b}\{a, b\}, has stack alphabet {⊥,A}\{\bot, A\}, and has three states {s,p,q}\{s, p, q\}, with ss being the start state. A transition from state uu to state vv, labelled c/X/γc/X/\gamma, where cc is an input symbol or ϵ\epsilon, XX is a stack symbol, and γ\gamma is a string of stack symbols, represents the fact that in state uu, the PDA can read cc from the input, with XX on the top of its stack, pop XX from the stack, push in the string γ\gamma on the stack, and go to state vv. In the initial configuration, the stack has only the symbol ⊥\bot in it. The PDA accepts by empty stack.

Which one of the following options correctly describes the language accepted by PP?
Question figure
Show answer without attempting

Answer: A

Q47

GATE CS 2022 CSContext Free LanguagesMSQ2 marks
Consider the following languages:

L1={anwan∣w∈{a,b}∗}L_1 = \{a^nwa^n \mid w \in \{a, b\}^*\}
L2={wxwR∣w,x∈{a,b}∗,∣w∣,∣x∣>0}L_2 = \{wxw^R \mid w, x \in \{a, b\}^*, |w|, |x| > 0\}

Note that wRw^R is the reversal of the string ww. Which of the following is/are TRUE?
More than one option can be correct.
Show answer without attempting

Answer: A, B, C

Q48

GATE CS 2022 CSContext Free LanguagesMSQ2 marks
Consider the following languages:

L1={ww∣w∈{a,b}∗}L_1 = \{ww \mid w \in \{a, b\}^*\}
L2={anbncm∣m,n≥0}L_2 = \{a^nb^nc^m \mid m, n \ge 0\}
L3={ambncn∣m,n≥0}L_3 = \{a^mb^nc^n \mid m, n \ge 0\}

Which of the following statements is/are FALSE?
More than one option can be correct.
Show answer without attempting

Answer: B, C, D

Q1

GATE CS 2021 CS-1Context Free LanguagesMCQ1 mark−1/3 if wrong
Suppose that L1L_1 is a regular language and L2L_2 is a context-free language. Which one of the following languages is NOT necessarily context-free?
Show answer without attempting

Answer: C

Q51

GATE CS 2021 CS-1Context Free LanguagesNAT2 marks
In a pushdown automaton P=(Q,Σ,Γ,δ,q0,F)P = (Q, \Sigma, \Gamma, \delta, q_0, F), a transition of the form,
p→a, X→Yqp \xrightarrow{a,\ X \to Y} q
where p,q∈Qp, q \in Q, a∈Σ∪{ϵ}a \in \Sigma \cup \{\epsilon\}, and X,Y∈Γ∪{ϵ}X, Y \in \Gamma \cup \{\epsilon\}, represents
(q,Y)∈δ(p,a,X).(q, Y) \in \delta(p, a, X).
Consider the following pushdown automaton over the input alphabet Σ={a,b}\Sigma = \{a, b\} and stack alphabet Γ={#,A}\Gamma = \{\#, A\}.
The number of strings of length 100 accepted by the above pushdown automaton is ______.
Question figure
Show answer without attempting

Answer: 50

Q12

GATE CS 2021 CS-2Context Free LanguagesMSQ1 mark
Let L1L_1 be a regular language and L2L_2 be a context-free language. Which of the following languages is/are context-free?
More than one option can be correct.
Show answer without attempting

Answer: B, C, D

Q41

GATE CS 2021 CS-2Context Free LanguagesMSQ2 marks
For a string ww, we define wRw^R to be the reverse of ww. For example, if w=01101w = 01101 then wR=10110w^R = 10110.
Which of the following languages is/are context-free?
More than one option can be correct.
Show answer without attempting

Answer: B, C, D

Q10

GATE CS 2020 CSContext Free LanguagesMCQ1 mark−1/3 if wrong
Consider the language L={an∣n≥0}∪{anbn∣n≥0}L = \{a^n \mid n \ge 0\} \cup \{a^n b^n \mid n \ge 0\} and the following statements.

I. LL is deterministic context-free.
II. LL is context-free but not deterministic context-free.
III. LL is not LL(kk) for any kk.

Which of the above statements is/are TRUE?
Show answer without attempting

Answer: C

0/200 correct0 marks

Related topics in Theory of Computation