You are on page 1of 2

COMP 310 (Spring 2019): Quiz 3 (Individual)

Submit your solutions to this take-home, open books/notes Quiz 3 before 10 p.m.,
Sunday, April 7, uploaded to Canvas. No late submissions will be accepted.

1 (20 points) Pumping Lemma for Regular Languages.


Use the pumping lemma for regular languages to show that the following language
is not regular:
L1 = { w ∈ {0,1,2,3,4,5,6,7,8,9}*: The number of odd digits (1,3,5,7,9) is equal to
the number of even digits (0,2,4,6,8) in w }

2 (20 points) Draw a dpda that accepts the following deterministic context-free
language:
L2 = { w ∈ {a,b}*: an(bb)n for n ≥1 }.
Enter your dpda into JFLAP and run the following 12 test cases as input strings:

abb
aabbbb
aaabbbbbb
aaaabbbbbbbb
a
bbbbaa
ab
aababb
aabb
aaabbbb
aabbbbbbbb

Page 1 of 2
3. (20 points) Determine whether each of the following ten languages are:
Regular
Deterministic context-free, but not regular
Context-free, but not deterministic context-free
Not context-free
In each case you do not have to prove your answer; simply state which of the 4
types of language it is.

L1 = { w{a,b,c}*: |w|a = |w|b = 2 |w|c }


L2 = { anbncn : n > 0 }
L3 = { anbmcp : n, m, p > 0, n ≠ m ≠ p }
L4 = { anbn : n > 0 }
L5 = { anbm : n, m > 0, n ≠ m }
L6 = { anbjanbj : n ≥ 0, j ≥ 0 }
L7 = { anbn: n < 1,000,000 }
L8 = { anbm : n, m > 0 }
L9 = { anwwRbn : n ≥ 0, w {a,b}* }
L10 = { anbncj : n  j }

4. (20 points) Eliminate useless productions from the context-free grammar:


S → aS | AB, A → bA, B → AA
5. (20 points) Consider the following grammar G: S → 0S1 | SS | 10
Show a parse tree produced by G for each of the following strings:
(a) 010110
(b) 00101101
Is G ambiguous? Why or why not?

Page 2 of 2

You might also like