Context Free Grammars questions — page 2 of 2

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

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

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/80 correct0 marks

Related topics in Context Free Languages