0% found this document useful (0 votes)
98 views19 pages

Carleton University

This document is the cover page for a final exam for the course COMP 2805B at Carleton University in Fall 2011. It provides exam instructions and details such as the exam duration of 3 hours, the number of students taking the exam, and the course instructor's name. It also lists what materials are allowed or required during the exam.

Uploaded by

Nizam CAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views19 pages

Carleton University

This document is the cover page for a final exam for the course COMP 2805B at Carleton University in Fall 2011. It provides exam instructions and details such as the exam duration of 3 hours, the number of students taking the exam, and the course instructor's name. It also lists what materials are allowed or required during the exam.

Uploaded by

Nizam CAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Carleton University

Final
Examination
Fall 2011

DURATION: 3 HOURS No. of students: 203

Department Name & Course Number: Computer Science COMP 2805B


Course Instructor: Michiel Smid

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.

In addition to this question paper, students require:


an examination booklet: no
a Scantron sheet: yes
COMP 2805B, FALL 2011 1

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

1. Which of the following strings is accepted by this DFA?

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) {w ∈ {a, b}∗ : w has an even number of b’s}


(b) {w ∈ {a, b}∗ : w has an odd number of b’s}
(c) {w ∈ {a, b}∗ : w does not contain the substring bbb}
(d) {w ∈ {a, b}∗ : w contains the substring bb}
COMP 2805B, FALL 2011 3

3. Which of the following strings is accepted by this NFA?

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) (ab ∪ aba)∗


(b) (ba ∪ aba)∗
(c) (ab)∗ (aba)∗
(d) None of the above.
COMP 2805B, FALL 2011 4

5. Which of the following is true?

(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) Every state of M must be an accept state.


(b) M does not have any accept state.
(c) The start state of M must be an accept state.
(d) None of the above.
COMP 2805B, FALL 2011 5

7. Consider the following NFA.


a
2 4

b

  a
1

a 
3 5

Assume we convert this NFA to an equivalent DFA (without removing unnecessary states).
Consider the following statements:

P : the start state of the DFA is {1, 2}.


Q : the DFA has 8 accept states.
R : when the DFA is in state {5} and reads an a, it switches to the state {1, 2, 3, 4, 5}.

Which of the following is correct?

(a) P is true, Q is true, R is false.


(b) P is false, Q is false, R is true.
(c) P is true, Q is true, R is true.
(d) P is true, Q is false, R is true.
8. Which of the following strings is in the language that is described by the regular expression
((a ∪ b)b∗ ab∗ )∗ .

(a) abbbb
(b) aaa
(c) bbaa
(d) aabbabb
COMP 2805B, FALL 2011 6

9. Let L be the language

L = {w ∈ {a, b}∗ : every a in w is followed by at most one b}.

Which of the following regular expressions describes the language L?

(a) b∗ (aa∗ ( ∪ b))∗


(b) b∗ (a∗ ( ∪ b))∗
(c) b∗ (a∗ ∪ a∗ b)∗
(d) None of the above.
10. What is the language described by the regular expression

c∗ (a ∪ bc∗ )∗

(a) {w ∈ {a, b, c}∗ : w contains the substring ac}


(b) {w ∈ {a, b, c}∗ : w does not contain the substring ac}
(c) {w ∈ {a, b, c}∗ : w contains the substring ab or ba}
(d) {w ∈ {a, b, c}∗ : w starts with c}
11. In this question, the alphabet is {a, b}. Consider the following statements:

P : Let R1 be a regular expression that describes the regular language L1 .


Let R2 be a regular expression that describes the regular language L2 .
Assume that  ∈ L1 and  ∈ L2 .
Then (a ∪ b)∗ and (R1 (a ∪ b)∗ R2 )∗ describe different languages.
Q : The regular expressions (a ∪ b)∗ and a∗ (ba∗ )∗ describe the same language.

Which of the following is correct?

(a) P is true, Q is true.


(b) P is true, Q is false.
(c) P is false, Q is true.
(d) P is false, Q is false.
12. True or false: There exists a regular expression that describes the language {an bn : n ≥ 0}.

(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

16. Consider the following DFA.

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?

(a) P is true, Q is true, R is true.


(b) P is true, Q is false, R is true.
(c) P is false, Q is true, R is true.
(d) P is false, Q is true, R is false.
17. Let L be a language consisting of a finite number of binary strings. Which of the following
is true?

(a) The Pumping Lemma for regular languages can be applied to L.


(b) The Pumping Lemma for regular languages cannot be applied to L.
COMP 2805B, FALL 2011 9

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?

(a) {an b : n ≥ 0} ∪ {abn : n ≥ 0}


(b) {an b : n ≥ 1} ∪ {abn : n ≥ 1}
(c) {bn a : n ≥ 1} ∪ {ban : n ≥ 1}
(d) {w ∈ {a, b} : w does not contain the substring ba}
COMP 2805B, FALL 2011 10

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?

(a) B must be context-free.


(b) B cannot be context-free.
(c) B may be context-free.
(d) None of the above.
COMP 2805B, FALL 2011 11

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?

(a) {w ∈ {a, b}∗ : w contains the substring bb}


(b) {w ∈ {a, b}∗ : w does not contain the substring aa}
(c) {w ∈ {a, b}∗ : w contains the substring ba}
(d) {w ∈ {a, b}∗ : w contains the substring aa}
COMP 2805B, FALL 2011 12

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}.

Which of the following is correct?

(a) P is true, Q is true.


(b) P is true, Q is false.
(c) P is false, Q is true.
(d) P is false, Q is false.
25. Let L = {am bn : 0 ≤ m ≤ n ≤ 2m}. Which of the following is correct?

(a) There exists an NFA whose language is L.


(b) There does not exist a context-free grammar whose language is L.
(c) There exists a non-deterministic pushdown automaton whose language is L.
(d) There does not exist a non-deterministic pushdown automaton whose language is L.
26. Let A = {www : w ∈ {a, b}∗ }. Assume we use the Pumping Lemma to prove that A is not a
context-free language. Which of the following strings can be used to obtain a contradiction?
(p denotes the pumping length.)

(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?

(a) a∗ ∪ b(a ∪ b)∗


(b) a∗ b ∪ b(a ∪ b)∗
(c) ba∗ ∪ b(a ∪ b)∗
(d) (a ∪ b)∗
COMP 2805B, FALL 2011 14

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?

(a) {w ∈ {a, b}∗ : w contains the substring aa}


(b) {w ∈ {a, b}∗ : w contains the substring ab}
(c) {w ∈ {a, b}∗ : w contains the substring ba}
(d) {w ∈ {a, b}∗ : w contains the substring bb}
COMP 2805B, FALL 2011 15

30. We proved in class that the Halting Problem is undecidable. Which proof technique did we
use?

(a) We used a proof by contradiction.


(b) We used the Pumping Lemma for decidable languages.
(c) We used induction on the number of states of the Turing machine that decides the
Halting Problem.
(d) We used Einstein’s Theory of Relativity.
31. Let M be a Turing machine with input alphabet {0, 1} and let w be a binary string.
We construct a new Turing machine TM w which takes as input an arbitrary binary string x:

Turing machine TM w (x) :


if x = 0n 1n for some n ≥ 0
then terminate in the accept state
else run M on the input string w;
if M terminates in the accept state
then terminate in the accept state
else if M terminates in the reject state
then terminate in the reject state
endif
endif
endif

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:

P : If M accepts w, then L(TM w ) is not a regular language.


Q : If M does not accept w, then L(TM w ) is a regular language.

Which of the following is correct?

(a) P is true, Q is true.


(b) P is true, Q is false.
(c) P is false, Q is true.
(d) P is false, Q is false.
COMP 2805B, FALL 2011 16

32. Consider the following statements:

P : For every decidable language L, the complement of L is also decidable.


Q : For every enumerable language L, the complement of L is also enumerable.

Which of the following is correct?

(a) P is true, Q is true.


(b) P is true, Q is false.
(c) P is false, Q is true.
(d) P is false, Q is false.
33. True or false: Let A be an enumerable language. Then there exists a Turing machine M
such that for any input string w,

w ∈ A if and only if M terminates on input w.

(a) True
(b) False
34. How do you feel?

(a) I need a beer.


COMP 2805B, FALL 2011 17
COMP 2805B, FALL 2011 18

You might also like