NEW
Font size
WorksheetsRegular Languages and Grammars Quiz
Total questions: 40
Worksheet time: 20mins
What is the language generated by this grammar? S→0S0|1S1|0A1|1A0 A→0A|1A|ϵ
Set of all palindromes over {0,1}
Set of all strings with equal number of 0′s and 1′s
Set of strings of even length
Set of all strings over {0,1} that are not palindromes
Which of the following is a regular language?
{a^nb^n|n≥0}
{a^mb^n|m,n≥0}
{a^nb^nc^n|n≥0}
{w∈{a,b}∗|w has equal number of a′s and b′s}
Which of the following languages is not regular?
{a^2n|n≥0}
{a^nb^m|m≤n}
{a^((n+1)^2−n^2)|n≥0}
{a^n|n is odd}
Which of the following statements is not true?
Every language that satisfies the pumping lemma is regular
Every regular language satisfies the pumping lemma
A language that does not satisfy the pumping lemma is not regular
Some non-regular languages satisfy the pumping lemma
Which of the following languages is not regular?
{a^p|p is a prime number}
{w∈{0,1}∗|w contains at most two 1's}
{w∈{0,1}∗|w ends with 00}
{w∈{0,1}∗| binary w is divisble by 5}
Which of the following regular expressions defines the same language as the CFG: S→A|ϵ,A→01A|01B,B→01B|ϵ
(10)∗
(01)∗
0∗1∗
0∗+1∗
Consider the following context-free grammar (CFG): S→1A0|0A1, A→0A0|1A1|ϵ Which of the following strings belongs to the language described by the above CFG?
1001
0110
1010
001100
Consider the following DFA: Which of the following CFGs generates the same language as the given DFA?
S→aA A→bB B→aB|bB|ϵ
S→bA A→aB B→aB|bBϵ
S→aS|bS|ϵ
S→abS|ϵ
Which CFG generates the same language as the regular expression (aba)∗?
S→abaS|ϵ
S→aSbSa|ϵ
S→aSa|bSb|ϵ
S→abS|baS|ϵ
Which of the following grammars is not ambiguous?
S→0S|1S|S0|S1|ϵ
S→SS|0|1
S→0S0|1S1|ϵ
S→A|B,A→0A|ϵ,B→1B|ϵ
Which of the following CFGs generates all palindromes over {a,b}?
S→aSa|bSb|a|b|ϵ
S→aSb|bSa|ϵ
S→aS|bS|ϵ
S→aaS|bbS|a|b
Chomsky Normal Form (CNF) requires productions to be in the form:
a) A → a or A → BC
b) A → aB or A → ε
c) A → aB | a
d) A → AB | aB
The language generated by grammar G: S → aS | Sb | ab is:
a) { a^n b^n | n ≥ 1 }
b) { a^m b^n | m, n ≥ 1 }
c) { a^n b^n | n ≥ 0 }
d) { a^n b^n | n ≥ 2 }
Which of the following statements is true?
a) Every regular language is also context-free.
b) Every context-free language is also regular.
c) Context-free languages are closed under intersection with each other.
d) Context-free languages are closed under complementation.
Consider the grammar G: S → aSb | ε The language L(G) is:
a) { a^n b^n | n ≥ 0 }
b) { a^n b^m | n, m ≥ 0 }
c) { w ∈ {a, b}* | w has equal a’s and b’s }
d) { a^n b^n c^n | n ≥ 0 }
Which of the following is a right-linear grammar?
a) S → aS | bS | ε
b) S → Sa | Sb | ε
c) S → AB, A → a, B → b
d) S → aSb
A grammar is called regular if:
a) Every production is of the form A → aB or A → a
b) Every production is of the form A → BC
c) Every production is of the form A → aB | ε
d) Both (a) and (c)
According to Myhill–Nerode theorem, a language L is regular iff:
a) It is accepted by a DFA
b) It has finitely many equivalence classes under the relation ≡L
c) It is closed under union and intersection
d) It can be expressed by a right-linear grammar
Two strings x and y are equivalent under Myhill–Nerode relation ≡L if:
a) x and y have the same length
b) x and y lead to the same state in DFA for L
c) For all z ∈ Σ*, xz ∈ L ⇔ yz ∈ L
d) x and y have the same number of symbols
The number of equivalence classes under Myhill–Nerode relation for a language L is equal to:
a) The number of productions in its grammar
b) The number of states in the minimal DFA for L
c) The number of terminal symbols in Σ
d) The length of the longest string in L
Consider L = { w ∈ {0,1}* | w ends with 01 }. How many equivalence classes does Myhill–Nerode theorem partition Σ* into?
a) 2
b) 3
c) 4
d) Infinite
For L = { a^n b^n | n ≥ 0 }, the Myhill–Nerode relation gives:
a) Finitely many equivalence classes → L is regular
b) Infinitely many equivalence classes → L is not regular
c) Equivalence classes equal to n
d) A DFA with 2 states
For L = { w ∈ {0,1}* | number of 1’s is divisible by 3 }, the number of equivalence classes under Myhill–Nerode theorem is:
a) 2
b) 3
c) Infinite
d) 6
Which of the following is the best application of Myhill–Nerode theorem?
a) Designing CFGs
b) Checking ambiguity of grammars
c) Proving that a language is not regular
d) Removing ε-productions
Pumping lemma fails for which language among the following?
a) L = { w ∈ {a, b}* | w has equal number of a’s and b’s }
b) L = { a^n b^n | n ≥ 0 }
c) L = { a^n b^m | n, m ≥ 0 }
d) Both (a) and (b)
The minimized DFA for any regular language is:
a) Unique
b) Not unique
c) May not exist
d) Depends on construction
The number of states in the minimal DFA for the language L = { w ∈ {0,1}* | w ends with 01 } is:
a) 2
b) 3
c) 4
d) 5
If L1 and L2 are regular languages, which of the following is always context-free but not necessarily regular?
a) L1 ∪ L2
b) L1 ∩ L2
c) L1 L2
d) L1 ∩ L where L is a CFL
Consider the grammar: S → SS | a This grammar is:
a) Unambiguous and generates {a^n | n ≥ 1}
b) Ambiguous and generates {a^n | n ≥ 1}
c) Ambiguous and generates {a^n b^n | n ≥ 1}
d) Unambiguous and generates {a^n b^n | n ≥ 1}
Which of the following grammars generates a regular language?
S → aS | Sb | ε
S → aS | b
S → aSb | ε
S → aA, A → bA | ε
Which of the following languages is generated by the grammar G: S → aSb | ε?
c) { a^n b^n | n ≥ 1 }
d) { a^n b^m | n = m }
b) { a^n b^m | n, m ≥ 0 }
a) { a^n b^n | n ≥ 0 }
For the language L = { w ∈ {0,1}* | w contains an even number of 0's }, how many states are required in the minimal DFA?
a) 1
b) 2
c) 3
d) 4
Which of the following statements about context-free languages is false?
c) Context-free languages are closed under intersection with regular languages.
a) Every context-free language can be represented by a pushdown automaton.
d) Context-free languages are closed under complementation.
b) Context-free languages are closed under union.
For a DFA with 6 states, initial partition in minimization is done based on:
a)
b)
States having the same number of incoming transitions
States with the same number of outgoing transitions
Final vs Non-final states
d)States having same alphabet symbols
The number of states in the minimized DFA is equal to:
Number of transitions in DFA
Number of equivalence classes under Myhill–Nerode relation
Number of terminals in alphabet Σ
Length of longest accepted string
If a DFA has n states, then the number of states in the minimized DFA is at least:
1
log₂ n
√n
n/2
Which of the following languages is context-free but not regular?
{ a^n b^n | n ≥ 0 }
{ a^n b^m | n, m ≥ 0 }
{ (ab)* }
{ a, b }*
(i) Every right-linear grammar generates a regular language.
(ii) Every regular language can be generated by some right-linear grammar.
(i) True, (ii) True
(i) True, (ii) False
(i) False, (ii) True
(i) False, (ii) False
According to the Myhill–Nerode theorem, the number of states in the minimal DFA for a language L is equal to:
|Σ|
The number of equivalence classes under ≡L
The number of productions in grammar
The number of terminal symbols
Consider the Deterministic Finite-state Automation (DFA) A shown below. The DFA runs on the alphabet {0, 1}, and has the set of states {s,p,q,r}, with being the start state p and being the only final state.
Which one of the following regular expressions correctly describes the language accepted by A?
1(0*11)*
0(0+1)*
1(0+11)*
1(110*)*
