0% found this document useful (0 votes)
8 views

Assignment#1

Theory of Automata Assignment questions solved

Uploaded by

Bakhtawar Tariq
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)
8 views

Assignment#1

Theory of Automata Assignment questions solved

Uploaded by

Bakhtawar Tariq
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/ 7

Advance Theory of Computation

Dr. Abdul Salam


Assignment # 1
Submitted by: Bakhtawar Tariq
______________________________________________________________________________
1. Let X = {I, 2, 3, 4, 5} and Y = {6, 7, 8, 9, 10}. The unary function f: X → Y and the
binary function g: X x Y → Y are described in the following tables.

a. What is the value of f (2)?


Ans. The value of f (2) = 7
b. What are the range and domain of f?
Ans. domain of function f is the input which is X = {1, 2, 3, 4, 5}.
Range is the output which is Y = {6, 7}
c. What is the value of g (2, 10)?
Ans. The value of g (2, 10) is 6.
d. What are the range and domain of g?
Ans. The domain of function g is (X, Y) which is: {(1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (2, 6), (2,
7), (2, 8), (2, 9), (2, 10), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (5,
6), (5, 7), (5, 8), (5, 9), (5, 10)}
The range is Y = {6, 7, 8, 9, 10}
e. What is the value of g (4, f (4))?
Ans. f (4) = 7 so g (4, f (4)) = g (4, 7) = 8

2. Write set of strings and complement set for each of the following languages.
a) L1 = {w  {a, b}*: each a in w is immediately preceded and immediately followed by a b}.
Ans. Set of strings L1 can have: L1 = {bab, bbabab, babbb…}
The complement will be the set of strings that do not satisfy the provided criteria and would be:
L1’= {a, aab, aaa, baab…}
b) L2 = {w  {a, b}*: w has abba as substring}.
Ans. abba as substring means it can come either at the beginning, end and in the middle. L2 =
{abba, aabba, aaabbabbb…}
The complement will the set of strings that do not satisfy the criteria or those that don’t have
abba as a substring.
L2’ = {aaa, bbb, bbbaab, abababaa…}
c) L3 = {w  {a, b}*: w has neither aa nor bb as a substring}.
Ans. Set of strings L3 can have: L3 = {a, b, ab, bab, aba, ababa…}
The complement will simply have strings containing aa and bb: L3 = {aabb, aabbabab,
aabaabb…}
d) L4 = {w  {a, b}*: w has an even number of substring ab}.
Ans. The set of Strings L4 can have: L4 = {abab, aaababababbbb, aaabbabbb…}.
The complement will be those that do not satisfy the criteria for L4: L4’= {ab, aaa, ababab,
abaaa, bbbab…}
e) L5 = {w  {a, b}*: w has both ab & ba as substrings}.
Ans. The set of strings L5 can have: L5 = {abba, abaaba, bbbabbbab…}.
The complement L5’ = {aaa, abaa, baaa, bbbba …}.

3. Construct DFA for each of the following languages using any Automata Simulator.
(Hand drawn answer is not accepted). Also give formal description of each DFA.
a) L6 = {w  {a, b}*: w contains a’s and b’s and end in bb}.
Following is the DFA for L6:
Formal Description:
Q (The finite set of states): {start, s0, s1, s2}
∑ (The finite set of symbols): {a, b}
δ: Q x Σ Q:
δ (start, a) = s0
δ (start, b) = start
δ (s0, a) = s0
δ (s0, b) = s1
δ (s1, a) = s0
δ (s1, b) = s2
δ (s2, a) = s0
δ (s2, b) = s2

qo (start state): start


F (Set of final states): {s2}

b) L7 = {w  {a, b}*: w contains different first and last letters. If a string begins with a, to be
accepted it must end with a b and vice versa}.
Following is the DFA for L7:
Formal Description:
Q (The finite set of states): {start, s0, s1, s2, s3}
∑ (The finite set of symbols): {a, b}
δ: Q x Σ Q
δ (start, a) = s0
δ (start, b) = s2
δ (s0, a) = s0
δ (s0, b) = s1
δ (s1, a) = s0
δ (s1, b) = s1
δ (s2, a) = s3
δ (s2, b) = s2
δ (s3, a) = s3
δ (s3, b) = s2

qo (start state): start


F (Set of final states): {s1, s3}

c) L8 = {w  {a, b}* :when w starts with a and has odd number of a’s or starts with b and has
even number of b’s }.
Following is the DFA for L8:
Formal Description:
Q (The finite set of states): {start, s0, s1, s2}
∑ (The finite set of symbols): {a, b}
δ: Q x Σ Q
δ (start, a) = s1
δ (start, b) = s0
δ (s0, a) = s2
δ (s0, b) = start
δ (s1, a) = start
δ (s1, b) = s2
δ (s2, a) = s0
δ (s2, b) = s1

qo (start state): start


F (Set of final states): {start, s1, s2}

d) L9 = {w  {a, b}* : w has three consecutive b’s (not necessarily at the end)}.
Following is the DFA for L9:
Formal Description:
Q (The finite set of states): {start, s0, s1, s2}
∑ (The finite set of symbols): {a, b}
δ: Q x Σ Q
δ (start, a) = start
δ (start, b) = s0
δ (s0, a) = start
δ (s0, b) = s1
δ (s1, a) = start
δ (s1, b) = s2
δ (s2, a) = s2
δ (s2, b) = s2

qo (start state): start


F (Set of final states): {s2}

e) L10 = {w  {a, b}* : w contain odd number of a’s and b’s


Following is the DFA for L10:

Formal Description:
Q (The finite set of states): {start, s0, s1, s2}
∑ (The finite set of symbols): {a, b}
δ: Q x Σ Q
δ (start, a) = s1
δ (start, b) = s0
δ (s0, a) = s2
δ (s0, b) = start
δ (s1, a) = start
δ (s1, b) = s2
δ (s2, a) = s0
δ (s2, b) = s1

qo (start state): start


F (Set of final states): {s2}

You might also like