Carleton University
Carleton University
Final
Examination
Fall 2011
Authorized memoranda:
NONE
Students MUST count the number of pages in this examination question paper
before beginning to write, and report any discrepancy to the proctor. This
question paper has 18 pages (not including the cover page).
This examination question paper MAY NOT be taken from the examination
room.
Student Name:
Student Number:
Instructions:
1. This is a closed book exam. No aids, notes, or calculating devices are allowed.
2. All questions must be answered on this examination paper as well as on the scantron
sheet.
Marking scheme: Each question is worth 3 marks, except the last one, which is worth 1
mark.
COMP 2805B, FALL 2011 2
a
b b
b
a a, b
(a) ababbbba
(b) bbabbb
(c) bbbbba
(d) ababba
2. Consider the DFA in the previous question. What is the language of this DFA?
a
b
(a) baba
(b) abaab
(c) abba
(d) baab
4. Consider the NFA in the previous question. Which of the following regular expressions
describes the language of this NFA?
(a) Let L be the language of the NFA M . If we turn every accept state into a non-accept
state, and turn every non-accept state into an accept state, then we obtain an NFA
whose language is the complement L̄ of L.
(b) NFA’s with -transitions can accept languages that cannot be accepted by any NFA
without -transitions.
(c) For every regular language L, there exists an NFA whose language is L and that has
exactly one accept state.
(d) There exists a language L consisting of a finite number of strings, such that L is not
regular.
6. Let M be an NFA with alphabet {0, 1} that accepts every binary string. Which of the
following is true?
a
3 5
Assume we convert this NFA to an equivalent DFA (without removing unnecessary states).
Consider the following statements:
(a) abbbb
(b) aaa
(c) bbaa
(d) aabbabb
COMP 2805B, FALL 2011 6
c∗ (a ∪ bc∗ )∗
(a) True
(b) False
COMP 2805B, FALL 2011 7
13. True or false: Let L be the language described by the regular expression a∗ b∗ , and let L0 be
the language described by the regular expression b∗ a∗ . Then the regular expression a∗ ∪ b∗
describes the language L ∩ L0 .
(a) True
(b) False
14. Recall that L1 − L2 denotes the difference of the languages L1 and L2 .
Thus, L1 − L2 = {w : w ∈ L1 , w 6∈ L2 }.
True or false: For any language L,
LL∗ = L∗ − {}.
(a) True
(b) False
15. Let Σ be a non-empty alphabet. Recall the rules that we used to define regular expressions
(RE) over this alphabet:
Rule 1: is a RE.
Rule 2: ∅ is a RE.
Rule 3: For each a ∈ Σ, a is a RE.
Rule 4: If R1 and R2 are RE’s, then R1 ∪ R2 is a RE.
Rule 5: If R1 and R2 are RE’s, then R1 R2 is a RE.
Rule 6: If R is a RE, then R∗ is a RE.
Is the following true or false: We do not need Rule 1, because it follows from Rule 2 and
Rule 6.
(a) True
(b) False
COMP 2805B, FALL 2011 8
a a
1 2
a
b
b 3
For each i = 1, 2, 3, let Li be the language of this DFA if we make i the start state. Consider
the following statements:
P : L1 = aL2 ∪ bL3
Q : L2 = a∗ bL3
R : L3 = b∗ ∪ b∗ aL1
Which of the following is correct?
18. Consider the context-free grammar G = (V, Σ, R, S), where V = {S, X, A, B} is the set of
variables, Σ = {a, b} is the set of terminals, S is the start variable, and R consists of the
following rules:
S → aXb
X → A|B
A → |aA
B → |bB
Which of the following strings is in the language of this grammar?
(a) aaaaab
(b) baaaab
(c) abaaaab
(d) aaabab
19. Consider the context-free grammar in the previous question. What is the language of this
grammar?
20. Consider the context-free grammar G = (V, Σ, R, S), where V = {S, A} is the set of variables,
Σ = {a, b} is the set of terminals, S is the start variable, and R consists of the following
rules:
S → AA
A → AAA|a|bA|Ab
Which of the following strings is in the language of this grammar?
(a) babbab
(b) bb
(c) bbbbb
(d) bba
21. Let A and B be languages such that A ⊆ B; thus, A is a subset of B. Assume that the
language A is context-free. Which of the following is true?
22. Consider the pushdown automaton with tape alphabet Σ = {a, b}, stack alphabet Γ = {$, S},
set of states Q = {q0 , q1 , q2 }, start state q0 , and instructions
q0 a$ → q1 R$S q1 aS → q2 R q2 a$ → q2 R$
q0 b$ → q0 R$ q1 bS → q0 R q2 b$ → q2 R$
q0 $ → q0 N $ q1 S → q1 N S q2 $ → q2 N
Recall that, at the start of the computation, the stack contains the symbol $ (and nothing
else). Which of the following strings is accepted by this pushdown automaton?
(a)
(b) baba
(c) babaab
(d) abba
23. Consider the pushdown automaton in the previous question. What is the language of this
pushdown automaton?
24. Recall that, for any string w = w1 w2 . . . wn−1 wn , we denote by wR the string obtained by
reversing w. Thus, wR = wn wn−1 . . . w2 w1 .
Consider the following statements:
P :
There exists a deterministic pushdown automaton whose language is
{wcwR : w ∈ {a, b}∗ }. Here, the alphabet is {a, b, c}.
Q : There exists a nondeterministic pushdown automaton whose language is
{wwR : w ∈ {a, b}∗ }. Here, the alphabet is {a, b}.
(a) s = ap bp ap bp .
(b) s = ap ap ap .
(c) s = ap bp ap bp ap bp .
(d) All of the above.
COMP 2805B, FALL 2011 13
27. Consider the Turing machine with input alphabet Σ = {a, b}, tape alphabet Γ = {a, b, },
set of states Q = {q, qaccept , qreject }, start state q, and instructions
qa → qaR
qb → qbL
q → qaccept
Recall that, at the start of the computation, the tape head is at the leftmost symbol of
the input string. Which of the following regular expressions describes the language of this
Turing machine?
28. Consider the Turing machine with input alphabet Σ = {a, b}, tape alphabet Γ = {a, b, },
set of states Q = {q0 , q1 , qaccept , qreject }, start state q0 , and instructions
q0 a → q1 aR
q0 b → q0 bR
q0 → qreject
q1 a → qaccept
q1 b → q0 bR
q1 → qreject
Recall that, at the start of the computation, the tape head is at the leftmost symbol of the
input string. Which of the following strings is accepted by this Turing machine?
(a)
(b) bbabaab
(c) ababab
(d) abba
29. Consider the Turing machine in the previous question. What is the language of this Turing
machine?
30. We proved in class that the Halting Problem is undecidable. Which proof technique did we
use?
Recall that L(TM w ) denotes the set of all binary strings x that are accepted by the Turing
machine TM w . Consider the following statements:
(a) True
(b) False
34. How do you feel?