02qbank PDF
02qbank PDF
02qbank PDF
Question 2
Using the pumping theorem, prove that the following languages are not regular:
a) {wwR : w ∈ {a, b}∗ }
∗
b) {ww : w ∈ {a, b} }
Minimum-state DFA
Question 1
Find the minimum-state equivalent deterministic finite automaton for each of the
following finite automata (deterministic in Figure 1 and nondeterministic in Figure
2).
a
b
a, b
a
e b
a, b
b b
b a e
a, b a, b
a
Figure 1: DFA Figure 2: NFA
1
Question 2
Problem 1.5.8 in Lewis and Papadimitriou (2nd. Edition).
Give examples to show that the intersection of two countably infinite sets can be
either finite or countably infinite, and that the intersection of two uncountable sets
can be finite, countably infinite, or uncountable.
Question 3
Let N ={0, 1, 2,..} be the set of whole numbers and Z = {.., -2, -1, 0, 1, 2 ..} be
the set of all integers.
Give a bijection between N and Z.
Question 4
Show that Z × Z is countable.
Question 5
Prove that:
a) The set of rational numbers, Q, is countably infinite
p
(Hint: every rational number can be expressed as q, where p ∈ Z, q ∈ N ,
q 6= 0, and p, q are relatively prime)
b) (Q. 1.5.11 in textbook) The set of all real numbers in the interval [0, 1] is
uncountable
(Hint: refer to the hint in textbook)
Context-free Grammars
Question 1
Show that the following languages are context-free by exhibiting context-free gram-
mars generating each.
(a) {am bn : m ≥ n}
(b) {am bn cp dq : m + n = p + q}
(c) {w ∈ {a, b}∗ : w has twice as many b’s as a’s}
(d) {w ∈ {a, b}∗ : w has equal number of a’s and b’s}
(e) {w ∈ {a, b}∗ : w = wR }
Question 2
Let G = (V, Σ, R, S), where V = {a, b, S}, Σ = {a, b}, and R = {S → aSb, S →
aSa, S → bSa, S → bSb, S → e}. Show that L(G) = {w ∈ {a, b}∗ : w has even length}.
2
Question 3
Prove that all regular languages are context-free.
(Hint: Recall that in class we showed how to construct the context-free grammar
corresponding to a particular DFA. You need to prove that the construction always
works correctly.)
Question 4
Construct a pushdown automaton that accepts the language {ai bj : i ≤ 2j}
Question 5
Construct a pushdown automaton that accepts the language {ai bj ck : i = j + k}
Pushdown Automata
Question 1
Consider the alphabet Σ = {a, b, (, ), ∪, ∗ , ∅}. Construct a context-free grammar
which generates all strings in Σ∗ that are regular expressions over {a, b}.
Question 2
Construct a pushdown automaton that accepts the following language:
Question 3
Use closure under union to show that the following languages are context-free.
a) {am bn : m 6= n}
b) {w ∈ {a, b}∗ : w = wR }
c) {am bn cp dq : n = q OR m ≤ p OR m + n = p + q}
d) {a, b} − {an bn : n ≥ 0}
∗
Question 4
In the proof of Theorem 3.5.2, why did we assume that M2 was deterministic?
3
Question 2
You are told that the language L = {an bn cn : n ≥ 0} is not context-free. Prove
that the following language is also not context-free:
Question 3
Suppose that L is context-free and R is regular. Are the following languages neces-
sarily context free? If yes, prove it; if not, give a counter-example.
a) L − R
b) R − L