All mock tests are FREE till 31 December — register to save your progress
Paper 2 CS · UNIT 08 · MOCK TEST

Mock 5 – Context-Free Grammars & PDA (Part 2)

Unit 8: Theory of Computation and Compilers · 30 questions · about 36 minutes. Press End Mock any time to see your score and the correct answers.

All 10 topic-wise mocks in this unit
0 / 30 answered 00:00
Q1.

What is the safest order while simplifying Context Free Grammar? ∈

Q2.

The reduced grammar equivalent to S → AB | CA, B → BC | AB, A → a, C → aB | b is

Q3.

Consider the grammar G: S → AbB, A → aAb | λ, B → bB | λ. Which language does G generate?

Q4.

Consider the grammar S → SbS | a. The string abababa has (A) two parse trees (B) two leftmost derivations (C) two rightmost derivations. Which is correct?

Q5.

Any string of terminals generated by the CFG S → XY, X → 0X | 1X | 0, Y → Y0 | Y1 | 0 (S is the start symbol)

Q6.

Let L1 = {0ⁿ1ⁿ0ᵐ | n ≥ 1, m ≥ 1}, L2 = {0ⁿ1ᵐ0ᵐ | n ≥ 1, m ≥ 1}, L3 = {0ⁿ1ⁿ0ⁿ | n ≥ 1}. Which are correct? A. L3 = L1 ∩ L2. B. L1 and L2 are context free but L3 is not. C. L1 and L2 are not context free but L3 is. D. L1 is a subset of L3.

Q7.

Given below are two statements

Statement I: The family of context free languages is closed under homomorphism

Statement II: The family of context free languages is closed under reversal In light of the above statements, choose the correct answer from the options given below

Q8.

Match List I (production rules) with List II (grammar). List I: A. S → XY, X → 0, Y → 1. B. S → aS | bSS | c. C. S → AB, A → 0A | 1A | 0, B → 0A. D. S → aAbc, Ab → bA, Ac → Bbcc, bB → Bb, aB → aa | aaA. List II: I. Greibach normal form, II. Context-sensitive grammar, III. Chomsky normal form, IV. S-grammar.

Q9.

Let L = L₁ ∩ L₂, where L₁ = {0ᵐ1ᵐ2 0ⁿ1ⁿ | m, n ≥ 0} and L₂ = {0ᵐ1ⁿ2ᵏ | m, n, k ≥ 0}. Then L is

Q10.

Which of the following statements is true?

Q11.

Let G1 and G2 be arbitrary context-free grammars and R an arbitrary regular language. Which problems are undecidable? (A) Is L(G1) = L(G2)? (B) Is L(G2) ⊆ L(G1)? (C) Is L(G1) = R?

Q12.

Which of the following grammars is (are) ambiguous? (A) S → SS | aSb | bSa | λ (B) S → aSbS | bSaS | λ (C) S → aAB, A → bBb, B → A | λ, where λ denotes the empty string

Q13.

Consider the following grammars : G : S → aSb|bSa|aa 1 G : S → aSb|bSa|SS ∣ λ 2 G : S → aSb|bSa|SS ∣ a 3 G : S → aSb|bSa|SS|SSS|λ 4 Which of the following is correct w.r.t. the above grammars? G G

Q14.

Which grammar generates L = {aⁿbⁿ⁻³ | n > 2} over Σ = {a, b}?

Q15.

Consider the following grammar :

S → 0A ∣ 0BB

A → 00A ∣ λ

B → 1B ∣ 11C

C → B Which language does this grammar generate?

Q16.

Consider the following statements with respect L = {anbn ∣ n ≥ 0} to the language

S : L2 1 is context free language

S : Lk 2 is conext-free language for any given k ≥ 1 ¯¯¯

S : L L∗ 3 and are context free languages Which one of the following is correct? S S

Q17.

Consider the following languages : L = {anbncm} ∪ {anbmcm}, n, m ≥ 0 1 L = {wwR ∣ w ∈ {a, b}*} 2 Where R represents reversible operation. Which one of the following is (are) inherently ambiguous language(s)? L

Q18.

Let G=(V, T, S, P) be any context-free grammar λ without any -productions or unit productions. Let K be the maximum number of symbols on the right of any production in P. The maximum number of production rules for any equivalent grammar in Chomsky normal form is given by: 1 − I Where denotes the cardinality of the set.

Q19.

Match List I with List II, where L1 is regular, L2 context-free, L3 recursive and L4 recursively enumerable. List I: (a) complement(L3) ∪ L4, (b) complement(L2) ∪ L3, (c) L1* ∩ L2. List II: (i) Context-free language, (ii) Recursively enumerable language, (iii) Recursive language.

Q20.

How can the decision algorithm be constructed L for deciding whether context-free language is finite? CFGG

(a) By constructing redundant in CNF L generating language −−

(b) By constructing non-redundant CFG G in CNF L generating language CFGG

(c) By constructing non-redundant in CNF L − {∧}(∧ generating language stands for null) Which of the following is correct?

Q21.

Consider the following grammar :

S → XY

X → Y aY ∣ a and Y → bbX Which of the following statements is/are true about the above grammar?

(a) Strings produced by the grammar can have a consecutive three 's.

(b) Every string produced by the grammar have a b alternate and .

(c) Every string produced by the grammar have a at least two 's. b

(d) Every string produced by the grammar have 's in multiple of 2.

Q22.

Consider L₁ = {a^(n+m) bⁿ aᵐ | n, m ≥ 0} and L₂ = {a^(n+m) b^(n+m) a^(n+m) | n, m ≥ 0}. Which one is correct?

Q23.

Consider to be any regular language and L , L 1 2 be any two context-free languages. Which one of the following is correct?

Q24.

Consider the grammar G: S → A | B, A → a | c, B → b | c, with non-terminals {S, A, B} and terminals {a, b, c}. S₁: LR(1) can parse all strings generated by G. S₂: LL(1) can parse all strings generated by G.

Q25.

The grammar S → (S) | SS | ε is not suitable for predictive parsing because the grammar is

Q26.

A pushdown automata behaves like a Turing machine when the number of auxiliary memory is :

Q27.

Pushdown automata can recognize language generated by_________.

Q28.

To obtain a string of n Terminals from a given Chomsky normal form grammar, the number of productions to be used is :

Q29.

Consider the two grammars: G₁: S → SbS | a G₂: S → aB | ab, A → AAB | a, B → ABb | b Which of the following options is correct?

Q30.

The set A= { 0n1n2n | n= 1, 2, 3,..............} is an example of a grammar that is :