Context Free Languages questions — page 2 of 2

Q31

GATE CS 2019 CSContext Free LanguagesMCQ2 marks−2/3 if wrong
Which one of the following languages over Σ={a,b}\Sigma = \{a, b\} is NOT context-free?
Show answer without attempting

Answer: C

Q35

GATE CS 2018 CSContext Free LanguagesMCQ2 marks−2/3 if wrong
Consider the following languages:

I. {ambncpdq∣m+p=n+q, where m,n,p,q≥0}\{a^m b^n c^p d^q \mid m + p = n + q, \text{ where } m, n, p, q \ge 0\}
II. {ambncpdq∣m=n and p=q, where m,n,p,q≥0}\{a^m b^n c^p d^q \mid m = n \text{ and } p = q, \text{ where } m, n, p, q \ge 0\}
III. {ambncpdq∣m=n=p and p≠q, where m,n,p,q≥0}\{a^m b^n c^p d^q \mid m = n = p \text{ and } p \neq q, \text{ where } m, n, p, q \ge 0\}
IV. {ambncpdq∣mn=p+q, where m,n,p,q≥0}\{a^m b^n c^p d^q \mid mn = p + q, \text{ where } m, n, p, q \ge 0\}

Which of the languages above are context-free?
Show answer without attempting

Answer: B

Q10

GATE CS 2017 CS-1Context Free LanguagesMCQ1 mark−1/3 if wrong
Consider the following context-free grammar over the alphabet Σ={a,b,c}\Sigma = \{a, b, c\} with SS as the start symbol:

S→abScT∣abcTS \to abScT \mid abcT
T→bT∣bT \to bT \mid b

Which one of the following represents the language generated by the above grammar?
Show answer without attempting

Answer: B

Q17

GATE CS 2017 CS-1Context Free LanguagesMCQ1 mark−1/3 if wrong
Consider the following grammar:

P→xQRSQ→yz∣zR→w∣εS→y\begin{aligned} P & \to xQRS \\ Q & \to yz \mid z \\ R & \to w \mid \varepsilon \\ S & \to y \end{aligned}

What is FOLLOW(Q)\text{FOLLOW}(Q)?
Show answer without attempting

Answer: C

Q34

GATE CS 2017 CS-1Context Free LanguagesMCQ2 marks−2/3 if wrong
If GG is a grammar with productions

S→SaS∣aSb∣bSa∣SS∣εS \to SaS \mid aSb \mid bSa \mid SS \mid \varepsilon

where SS is the start variable, then which one of the following strings is not generated by GG?
Show answer without attempting

Answer: D

Q37

GATE CS 2017 CS-1Context Free LanguagesMCQ2 marks−2/3 if wrong
Consider the context-free grammars over the alphabet {a,b,c}\lbrace a, b, c \rbrace given below. SS and TT are non-terminals.

G1:S→aSb∣T,T→cT∣εG_1: S \to aSb \mid T, T \to cT \mid \varepsilon
G2:S→bSa∣T,T→cT∣εG_2: S \to bSa \mid T, T \to cT \mid \varepsilon

The language L(G1)∩L(G2)L(G_1) \cap L(G_2) is
Show answer without attempting

Answer: B

Q38

GATE CS 2017 CS-1Context Free LanguagesMCQ2 marks−2/3 if wrong
Consider the following languages over the alphabet Σ={a,b,c}\Sigma = \lbrace a, b, c \rbrace. Let L1={anbncm∣m,n≥0}L_1 = \lbrace a^n b^n c^m \mid m, n \ge 0 \rbrace and L2={ambncn∣m,n≥0}L_2 = \lbrace a^m b^n c^n \mid m, n \ge 0 \rbrace.

Which of the following are context-free languages?

I. L1∪L2L_1 \cup L_2
II. L1∩L2L_1 \cap L_2
Show answer without attempting

Answer: A

Q4

GATE CS 2017 CS-2Context Free LanguagesMCQ1 mark−1/3 if wrong
Let L1,L2L_1, L_2 be any two context-free languages and RR be any regular language. Then which of the following is/are CORRECT?

I. L1∪L2L_1 \cup L_2 is context-free.
II. L1‾\overline{L_1} is context-free.
III. L1−RL_1 - R is context-free.
IV. L1∩L2L_1 \cap L_2 is context-free.
Show answer without attempting

Answer: B

Q16

GATE CS 2017 CS-2Context Free LanguagesMCQ1 mark−1/3 if wrong
Identify the language generated by the following grammar, where SS is the start variable.

<br>S→XY<br>X→aX∣a<br>Y→aYb∣ϵ<br>\begin{aligned}<br>S &\rightarrow XY \\<br>X &\rightarrow aX \mid a \\<br>Y &\rightarrow aYb \mid \epsilon<br>\end{aligned}
Show answer without attempting

Answer: C

Q42

GATE CS 2016 CS-1Context Free LanguagesMCQ2 marks−2/3 if wrong
Consider the following context-free grammars:
G1:S→aS∣B,B→b∣bBG_1: S \to aS|B, B \to b|bB
G2:S→aA∣bB,A→aA∣B∣ϵ,B→bB∣ϵG_2: S \to aA|bB, A \to aA|B|\epsilon, B \to bB|\epsilon
Which one of the following pairs of languages is generated by G1G_1 and G2G_2, respectively?
Show answer without attempting

Answer: D

Q43

GATE CS 2016 CS-1Context Free LanguagesMCQ2 marks−2/3 if wrong
Consider the transition diagram of a PDA given below with input alphabet Σ={a,b}\Sigma = \{a,b\} and stack alphabet Γ={X,Z}\Gamma = \{X,Z\}. ZZ is the initial stack symbol. Let LL denote the language accepted by the PDA.

Which one of the following is TRUE?
Question figure
Show answer without attempting

Answer: D

Q18

GATE CS 2016 CS-2Context Free LanguagesMCQ1 mark−1/3 if wrong
Consider the following types of languages: L1L_1 : Regular, L2L_2 : Context-free, L3L_3 : Recursive, L4L_4 : Recursively enumerable. Which of the following is/are TRUE?

I. L3‾∪L4\overline{L_3} \cup L_4 is recursively enumerable
II. L2‾∪L3\overline{L_2} \cup L_3 is recursive
III. L1∗∩L2L_1^* \cap L_2 is context-free
IV. L1∪L2‾L_1 \cup \overline{L_2} is context-free
Show answer without attempting

Answer: D

Q43

GATE CS 2016 CS-2Context Free LanguagesMCQ2 marks−2/3 if wrong
Consider the following languages:
L1={anbmcn+m:m,n≥1}L_1 = \{a^n b^m c^{n+m} : m,n \ge 1\}
L2={anbnc2n:n≥1}L_2 = \{a^n b^n c^{2n} : n \ge 1\}

Which one of the following is TRUE?
Show answer without attempting

Answer: B

Q46

GATE CS 2016 CS-2Context Free LanguagesMCQ2 marks−2/3 if wrong
A student wrote two context-free grammars G1\mathbf{G_1} and G2\mathbf{G_2} for generating a single C-like array declaration. The dimension of the array is at least one. For example,
int a[10][3];
The grammars use DD as the start symbol, and use six terminal symbols int ; id [ ] num.
Grammar G1\mathbf{G_1}Grammar G2\mathbf{G_2}
D→int L;D \to \textbf{int}\, L;D→int L;D \to \textbf{int}\, L;
L→id [EL \to \textbf{id}\, [EL→id EL \to \textbf{id}\, E
E→num ]E \to \textbf{num}\, ]E→E[num]E \to E[\textbf{num}]
E→num ][EE \to \textbf{num}\, ][EE→[num]E \to [\textbf{num}]
Which of the grammars correctly generate the declaration mentioned above?
Show answer without attempting

Answer: A

Q44

GATE CS 2015 CS-3Context Free LanguagesMCQ2 marks−2/3 if wrong
Which of the following languages are context-free?

L1={ambnanbm∣m,n≥1}L2={ambnambn∣m,n≥1}L3={ambn∣m=2n+1} \begin{array}{l} L_1 = \{a^m b^n a^n b^m \mid m, n \ge 1\} \\ L_2 = \{a^m b^n a^m b^n \mid m, n \ge 1\} \\ L_3 = \{a^m b^n \mid m = 2n + 1\} \end{array}
Show answer without attempting

Answer: B

Q50

GATE CS 2015 CS-1Context Free LanguagesMCQ2 marks−2/3 if wrong
Consider the NPDA ⟨Q={q0,q1,q2},Σ={0,1},Γ={0,1,⊥},δ,q0,⊥,F={q2}⟩\langle Q = \{q_0, q_1, q_2\}, \Sigma = \{0, 1\}, \Gamma = \{0, 1, \bot\}, \delta, q_0, \bot, F = \{q_2\} \rangle, where (as per usual convention) QQ is the set of states, Σ\Sigma is the input alphabet, Γ\Gamma is the stack alphabet, δ\delta is the state transition function, q0q_0 is the initial state, ⊥\bot is the initial stack symbol, and FF is the set of accepting states. The state transition is as follows:

Which one of the following sequences must follow the string 101100 so that the overall string is accepted by the automaton?
Question figure
Show answer without attempting

Answer: B

Q36

GATE CS 2014 CS-3Context Free LanguagesMCQ2 marks−2/3 if wrong
Consider the following languages over the alphabet Σ={0,1,c}\Sigma = \{0, 1, c\}:

L1={0n1n∣n≥0}L_1 = \{0^n1^n \mid n \ge 0\}
L2={wcwr∣w∈{0,1}∗}L_2 = \{wcw^r \mid w \in \{0, 1\}^*\}
L3={wwr∣w∈{0,1}∗}L_3 = \{ww^r \mid w \in \{0, 1\}^*\}

Here, wrw^r is the reverse of the string ww. Which of these languages are deterministic Context-free languages?
Show answer without attempting

Answer: C

Q32

GATE CS 2013 CSContext Free LanguagesMCQ2 marks−2/3 if wrong
Consider the following languages.

L1={0p1q0r∣p,q,r≥0}L_1 = \{0^p 1^q 0^r \mid p, q, r \ge 0\}
L2={0p1q0r∣p,q,r≥0,p≠r}L_2 = \{0^p 1^q 0^r \mid p, q, r \ge 0, p \neq r\}

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

Answer: D

0/180 correct0 marks

Related topics in Theory of Computation