COS2601/2016
Assignments 2016
Theoretical Computer Science 2
COS2601
Semester 1
Assignment 1
School of Computing
COS2601/2016
Semester 1: Assignment 01
Material to be tested
Additional material
Submission procedure
Weight towards semester mark
Cohen, Chap
COS2601
Theoretical Computer Science II
Solution to Selftest B
Hints for finding a regular expression that generates a language accepted by a given TG (transition
graph). (Refer to the algorithm in Kleenes theorem provided on p 106 in Cohen.)
Hints:
Cre
COS2601
Theoretical Computer Science II
Question C.5
Problem 13(iii) on page 220 in the 1997 edition.
Answer
The given FA:
a

b
b
a, b
a
+
The first part of Theorem 19, page 215 in Cohen states:
Let F be an FA with N states. If F accepts an input string
COS2601
Theoretical Computer Science II
Question C.4
Problem 4 on page 217 in the 1997 edition.
Answer
We have to decide whether or not FA1 and FA2 are equivalent. We provide the given FA's with numbered
states:
FA1:
a
X1
+X2
a
b
b
b
a
+X3
FA2:
a,b
r
1
I
COS2601
Theoretical Computer Science II
Question C.3
Use the pumping lemma with length to prove that the following language is nonregular:
L = cfw_abn+1an, with n cfw_0, 1, 2, 3, . .
Answer
Assume L = cfw_abn+1an, where n cfw_0, 1, 2, 3, . is regular.
Th
COS2601
Theoretical Computer Science II
Question C.2
Define the language L as follows:
L = cfw_an!bn! = cfw_ab aabb aaaaaabbbbbb
Prove that L is nonregular by using the pumping lemma with length.
Answer
Let L = cfw_an!bn! = cfw_ab, aabb, aaaaaabbbbbb, .
(
COS2601
Theoretical Computer Science II
Selftest C Questions
Question C.1
Problem 8 on page 185 in the 1997 edition.
Question C.2
Define the language L as follows:
L = cfw_an!bn! = cfw_ab aabb aaaaaabbbbbb
Prove that L is nonregular by using the pumping
COS2601
Theoretical Computer Science II
Question B.1
Use Kleene's theorem to find a regular expression that generates the language accepted by the
following TG (Transition Graph):
a,b
baa
a,b
+

+
abb
Answer
Note: When a state must be eliminated, each in
COS2601
Theoretical Computer Science II
Question B.4
Problem 14(vii) on page 146 in the 1997 edition, but do not use the constructive algorithm presented in
Proof 2 of Theorem 7. Instead analyse the NFA, decide which language is accepted by the NFA, and
t
COS2601
Theoretical Computer Science II
Question B.3
Build a (deterministic) FA which accepts the same language as the following NFA:
b
a, b
b
a
a
a
a
a
a
b
+
a, b
Answer
First of all we have to determine which language is accepted by the given NFA. Well,
COS2601
Theoretical Computer Science II
Question B.2
Problem 5(i) on page 143 in the 1997 edition.
Answer
The states of the respective machines are numbered as follows:
FA1:w1 and +w2
FA2:x1 and x2 and +x3
b
FA1:
W1
b
a
+W2
a
FA2:
b
X1
a,b
a
b
X2
X3+
COS2601
Theoretical Computer Science II
Selftest B Questions
Question B.1
Use Kleene's theorem to find a regular expression that generates the language accepted by the
following TG (Transition Graph):
a, b
a, b
baa
x1
+x2
abb
Question B.2
Problem 5(i) o
COS2601/202/1/2016
Tutorial Letter 202/1/2016
Theoretical Computer Science 2
COS2601
Semester 1
School of Computing
This tutorial letter contains the
discussion of assignment 02.
Dear student,
By this time you should have received the tutorial matter list
KHANacademy
Subject: Computer sci
ALGORITHMS
Recursive algorithms
Challenge: Recursive factorial
Home
1
grantav
Using recursion to determine
whether a word is a palindrome
A palindrome is a word that is spelled the
Properties of recursive
algorithms
COS2601
Theoretical Computer Science II
Question C.1
Problem 8 on page 185 in the 1997 edition.
Answer
(Note: We recommend that you follow the first shortcut method by applying the algorithm presented in
the GOOD PROOF of Theorem 12 if you are asked a sim