You are on page 1of 4

SCJ3253TheoryofComputerScience

ANSWERTutorial4:FiniteAutomata(Part1)

1. YouaregiventheDFAwithstatesq0,q1,q2havingq2asfinalstateand{a,b}asinput
alphabet.Theprogramisgivenbythetable:

q0
q1
q2

a
q0
q2
q2
a

b
q1
q1
q0
b

q0

q1

q2

a) GiveastatediagramforthisDFA.
b) Tracethecomputationsthatprocessthestringsabaa,bbbabb,bababa,andbbbaa.

[q0,abaa][q0,baa]
[q1,aa]
[q2,a]
[q2,]
Stopatq2(finalstate)andallalphabetistraced(stringisempty);
Hence,stringabaaisacceptedbymachine.

[q0,bbbabb][q1,bbabb]
[q1,babb]
[q1,abb]
[q2,bb]
[q0,b]
[q1,]
Allalphabetistraced(stringisempty)butstopatq1(notfinalstate);
Hence,stringbbbabbisnotacceptedbymachine.

[q0,bababa][q1,ababa]
[q2,baba]
[q0,aba]
[q0,ba]
[q1,a]
[q2,]
Stopatq2(finalstate)andallalphabetistraced(stringisempty);
Hence,stringbababaisacceptedbymachine.

[q0,bbbaa][q1,bbaa]
Disediakan oleh: Zalmiyah Zakaria, FSKSM, UTM

( m/s: 48 )

SCJ3253TheoryofComputerScience

[q1,baa]
[q1,aa]
[q2,a]
[q2,]
Stopatq2(finalstate)andallalphabetistraced(stringisempty);
Hence,stringbbbaaisacceptedbymachine.

c) Whichofthestringsinb)areacceptedbytheDFA?
d) GivearegularexpressionforthelanguageacceptedbytheDFA.
a*bb*a(a+ba*bb*a)*OR
a*b+a(a+ba*b+a)* sincebb*=b+

2. Designafiniteautomatonandregulargrammartoacceptthelanguagedefinedbythe
followingregularexpression
c. a*b*
q0 aq0bq1
q1 bq1

b
b

q0

q1

q0 aq1bq0

a. (a+b)*
a,b

q0

b. (ab)*

q0 aq1
q1 bq0

q0

q1

c. (ab)*ba

d. (ab*a)*

q0
q1
q2
q3

aq1bq2
bq0
aq3

q0 aq1
q1 bq1aq0

Disediakan oleh: Zalmiyah Zakaria, FSKSM, UTM

( m/s: 49 )

SCJ3253TheoryofComputerScience

3. Considerthefollowingregulargrammar:
a. DesignafiniteautomatontoacceptthelanguageEvenstringconsistingofallstrings
over{a,b}ofevenlength.Hint:Aregulargrammarforthelanguageis

S aObO
O aSbS

a,b

q0
q1

a,b

b. Givearegularexpressionforthelanguage.((a+b)(a+b))*

4. Considerthefollowingregulargrammar:
S aBbA
A aCbS
B aSbC
C aAbB
a. DesignafiniteautomatontoacceptthelanguageEvenEvenconsistingofallstringsover
{a,b}withanevennumberofasandanevennumberofbs.
a
S

a
b

b
b

b. Write5strings(includingtheshortest)thatcanbegeneratedfromthislanguage.aa,bb,
abba,baab,baaaab,abab.

5. Designafiniteautomatontoacceptthelanguageasdescribedbelow:
a. Thesetofstringsover{a,b}thatdoNOTbeginwiththesubstringaaa.

6. ConsiderthefollowingregulargrammarG:
S
bA
A
aCbB
B
bA
C
aD
D
aC

Disediakan oleh: Zalmiyah Zakaria, FSKSM, UTM

( m/s: 50 )

SCJ3253TheoryofComputerScience

a. DesignafiniteautomatontoacceptthelanguageasdescribedbygrammarG.

b. Givearegularexpressionforthelanguage.b(bb)*aa(aa)*

Disediakan oleh: Zalmiyah Zakaria, FSKSM, UTM

( m/s: 51 )

You might also like