Professional Documents
Culture Documents
COS2601/102/1/2020
Semester 1
School of Computing
BARCODE
COS2601/102/1/2020
Dear student
Hope you are well on your way to familiarise yourself with the content of COS2601. This tutorial letter
contains the three assignments for the first semester. Best wishes for your COS2601 studies!
Regards
COS2601 team
SEMESTER 1 - ASSIGNMENT 1
Material to be tested Cohen, Chapters 1 – 4
Note: In all questions where some given languages are mentioned, they are defined over {a b} unless
otherwise stated.
Question 1
Consider the language S*, where S = {ba bab bba}. Which one of the following words is in this language?
1. bbababb
2. babbaababa
3. babbbabbbabba
4. bababab
Question 2
Which one of the following is an example of two sets S and T of strings such that S T and T S, but S*
≠ T*?
COS2601/102/1/2020
Question 3
Consider the language S*, where S = {bb, bab}. Which one of the following words is not in the language
S*?
1. bbabb
2. babbb
3. bbbab
4. babbabbb
Question 4
Which one of the following is an example of a set S such that the language S* has less 5-letter words than
3-letter words?
1. S = {aaa, ba, a}
2. S = {aaa, aa, bb, a}
3. S = {aabba, aabb, bbb, aaa}
4. S = {babbb, b, bab}
Question 5
Consider the language EVENABAB over the alphabet ∑ = {a b} consisting of all words of even length that
contain the substring abab. Which one of the following is a suitable generator?
1. abab
2. ab
3. a
4.
Question 6
Consider the language MultipleOfFourNotAAandB consisting of all words of a length which is divisible by
4 without a remainder that do not contain an aa-substring but contains a b-substring. Which one of the
following can be used as one of the generators of the language?
1. babababa
2. Λ
3. aaba
4. baba
COS2601/102/1/2020
Question 7
Which one of the following regular expressions generates a language equivalent to the language
generated by (ab + ba)*?
1. (abba)*
2. ((ab)*(ba)*)*
3. (a + b)*
4. (aa + ab)*ba
Question 8
Which one of the following regular expressions defines the language of all strings that ends on an a- or an
abbb-substring?
1. (a + b)*a + (a + b)*bbb
2. (a + b)*a(a + b)*bbb(a + b)*
3. (a + b)*a( + bbb)
4. (a + b)*(a + bbb)
Question 9
Which one of the following words cannot be generated by the regular expression?
(b + a)*(ab + ba)(b) ?
1. abbabbb
2. babbbabab
3. baabbbbbab
4. babb
Question 10
Which one of the following regular expressions generates a language equivalent to the language
generated by the regular expression?
COS2601/102/1/2020
SEMESTER 1 - ASSIGNMENT 2
Material to be tested Cohen, Chapters 3 – 6
Provide detailed solutions to all questions. It is possible that not all these questions will be marked. We
will decide in advance which of them (or all) to mark and you will not be informed in advance about the
decision.
Note: In all questions where some given languages are mentioned, they are defined over {a b} unless
otherwise stated.
Question 1
A recursive definition for the language ODDnotAB over the alphabet ∑= {a b} must be compiled where
ODDnotAB has as elements all words that are of odd length and do not contain the ab-substring.
Give
(i) an appropriate universal set,
(ii) the generator(s) of ODDnotAB, and
(iii) an appropriate function on the universal set, and then
(iv) use these concepts to write down a recursive definition of the language ODDnotAB.
Question 2
(i) Give a recursive definition of the set P of all positive integers greater than 0,
(ii) formulate the appropriate induction principle, and then
(iii) use mathematical induction to prove that
11 + 15 + 19 + … + (4n + 7) = 2n2 + 9n
Question 3
Construct a regular expression that defines the language M (say) containing all words with either exactly
one single a-substring or all words with only ab-substrings. (Words such as aa, aabaab, aabbbaaabbb and
Λ do not belong to M.)
COS2601/102/1/2020
Question 4
Construct a regular expression that defines the language L containing all the words with either exactly one
aba-substring or exactly one bab-substring but not both aba- and bab-substrings.
(Hint: For example, the word abab does not belong to L.)
Question 5
Build an FA that accepts the language P consisting of all words with no aa-substring.
Question 6
Build an FA that accepts the language consisting of only those words that do not end in ab.
Question 7
a TG which accepts the language of all strings consisting of at least 4 characters such that the next-to-last
letter is identical to the second letter. Use as few states as possible.
COS2601/102/1/2020
SEMESTER 1 - ASSIGNMENT 3
Material to be tested Cohen, Chapters 7 – 11
Note: In all questions where some given languages are mentioned, they are defined over {a b} unless
otherwise stated.
Question 1
Kleene's theorem should be used to find a regular expression that generates the language accepted by
the following TG (Transition Graph):
b a, b
aa
z1 z2
bab ^
^
- b ab +
bb ^
^
z6 a z4 b
In the process, states are eliminated until only the start and end states
are left with an edge connecting them and with a label that represents the required regular expression.
Which one of the following is not a label of a required path when state z2 is eliminated?
COS2601/102/1/2020
Question 2
–w1
b a a, b
b
w2 +w3
By applying Kleene’s theorem, an FA must be built for the regular expression r*. In the process a transition
table is compiled. Which one of the following tables is the correct table in the solution for this problem?
1.
New state Read an a Read an b
±z1 = w1 z2 z3
z2 = w1 z2 z3
z3 = w2 z2 +z4
+z4 = w1 or w3 +z4 +z5
+z5 = w1 or w2 or w3 +z4 +z5
2.
New state Read an a Read an b
z1 = w1 z1 z2
z2 = w2 z1 +z3
+z3 = w1 or w3 +z3 +z4
+z4 = w1 or w2 or w3 +z3 +z4
3.
New state Read an a Read an b
±z1 = w1 ±z1 z2
z2 = w2 ±z1 +z3
+z3 = w1 or w3 +z3 +z4
+z4 = w1 or w2 or w3 +z3 +z4
4.
New state Read an a Read an b
z1 = w1 z1 z2
z2 = w2 z1 +z3
+z3 = w3 +z3 +z3
COS2601/102/1/2020
Question 3
q0 /0 b q2 /1
a a a
b
a
q1 /1 q3 /1 b
b
1. 11110111
2. 011110111
3. 111110111
4. 0111110111
Question 4
a/0
q0 q2
b/1
b/0
q1 q3
b/1
a/0
The given Mealy machine must be converted to a Moore machine. Which one of the diagrams provided in
the following options represents the required Moore machine?
COS2601/102/1/2020
1.
q0 /0 b q2 /1
a a
b
q21 /0 a
a q1 3 /1 b
a a
b
a q23 /0
q11 /1 b
2.
q0 /0 b q2 /1
a a
a b
q21 /0
a q1 3 /1 b
a b
b q23 /0
b
q11 /1 a
3.
q0 /0 b q2 /1
a a
q21 /0 b
a b
a
b q3 /1
b
q1 1 /1 a
4.
q0 /0 b q2 /1
a
a b b
a
q3 /1
b
q1 /1 a
10
COS2601/102/1/2020
Question 5
The set of regular languages is closed under (a) certain operation(s). Which one of the following
alternatives provides (all) this/these possible operation(s)?
Question 6
b
+ x2 a, b
b
± x1
b a x4
a
+ x3
a
and
b a, b
a
a
- y2 +
y1 y3
b
11
COS2601/102/1/2020
+z2
a
-z1
a a, b
b
z3
b
2.
z2
a
-z1
a a, b
b
+z3
b
3.
z2
a a a, b
-z1 z4
a b
b
z3
b
4.
z2
a a a, b
-z1 +z4
a b
b
z3
b
12
COS2601/102/1/2020
Question 7
1. The language {baban, with n {2, 3, 4, ...}, n ∈ ℤ} can be generated by the regular expression baba*.
2. There exists an FA that accepts the nonregular language {banc, with n {1, 3, 4, ...}, n ∈ ℤ}.
3. If a finite set of words is added to a nonregular language, the result is a nonregular language.
4. {anbn} = a*b*.
Question 8
The following question is given: Use the Pumping Lemma with length to prove that the following language
is nonregular:
Which one of the following is not one of the possible correct choices for y?
Question 9
By applying the decision procedure described in the theorem proof to the following FA, what will the
conclusion be?
b
a a a, b
- b a
b a, b b
+
13
COS2601/102/1/2020
Question 10
The blue paint procedure must be applied to determine whether or not the following FA accepts any words:
a
a
a a
- b a b +
b
b b
b a
Which one of the following diagrams represents the final diagram in the solution to the given problem?
1.
- +
14
COS2601/102/1/2020
2.
a
a
- +
3.
- +
4.
a
a
- +
b
b
b a
UNISA
©
2019
15