100% found this document useful (1 vote)
86 views10 pages

Aleena Automata2

This document contains the solutions to various questions about finite automata (FAs). It includes: 1) Transition tables for FAs defined in textbook pages 56, 58, 63, 64, and 69. 2) An FA and regular expression that accepts words with 'b' as the second letter. 3) An FA that accepts the strings 'baa', 'ab', and 'abb'. 4) FAs with different numbers of accepting states. 5) FAs that accept words with more than 4 letters, fewer than 4 letters, and exactly 4 letters. 6) An FA that does not accept words ending in 'ba'. 7) An FA that

Uploaded by

meesam2021
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
100% found this document useful (1 vote)
86 views10 pages

Aleena Automata2

This document contains the solutions to various questions about finite automata (FAs). It includes: 1) Transition tables for FAs defined in textbook pages 56, 58, 63, 64, and 69. 2) An FA and regular expression that accepts words with 'b' as the second letter. 3) An FA that accepts the strings 'baa', 'ab', and 'abb'. 4) FAs with different numbers of accepting states. 5) FAs that accept words with more than 4 letters, fewer than 4 letters, and exactly 4 letters. 6) An FA that does not accept words ending in 'ba'. 7) An FA that

Uploaded by

meesam2021
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/ 10

NAME: ALEENA SEHAR

ROLL NO: BSCS-2021-35

THEORY OF COMPUTATION
ASSIGNMENT #1
INSTRUCTOR: PROFESSOR RAMZAN SHAHID

Ques on No 1: Write out transi on tables for the FA’s on pages 56,58,63,64 and 69 that were
defined by pictures.
TRANSITION TABLE PAGE#56:
a b
x- y z+
y x- z+
z+ z+ z+

TRANSITION TABLE PAGE#58


a b
- + +
+ + +

THEN
a b
± ± ±

TRANSITION TABLE PAGE#63


a b
1- (start) 2 3
2 4+ 3
3 2 4+
4+ (final) 4+ +4+

THEN,
a b
1- (start) 2 2
2 3 3
3 4 5+
4 4 4
5+ (final) 5+ 5+

THEN,
a b
-(Start) q3 q1
q1 q2 q3
q2 q3 q3
q3 + q3
+(final) q3 q3
TRANSITION TABLE PAGE#69
a b
1 +- (start and final) 3 2
2 4 1+-
3 1+- 4
4 2 3

Ques on No 2: Build an FA that accepts only the language of all words with b as the second
le er. Show both the picture and the transi on table for this machine and find a regular
expression for the language.

SOLUTION:
Regular expression for the words with b as the second le er:

(a+b)b(a+b)*

TRANSITION DIAGRAM:

TRANSITION TABLE:

State a b
q0 q1 q1
q1 q3 q2
q2 q2 a2
q3 q3 q3

REGULAR EXPRESSION:
(a+b) b*(a+b)
Ques on No 3: Build an FA that accepts only the words baa, ab, and abb and no other strings
longer or shorter.

SOLUTION:

Ques on No 4: i. Build a new FA with three states that accepts all strings
ii. Show that FA with three states and three + ‘s, it accepts all input strings.
iii. If an FA has three states and only one +, must it rejects some inputs.

i)SOLUTION:
ii)SOLUTION:

iii) SOLUTION:
yes the third one will reject some input strings. For example if the string is only a, then it will end
up in q1 which isnt final state and wont be accepted. Similar is the case with b

NOTE:
note that the arrow from upper state to lower state has text on le side and lower state to upper
state text is on le side.

Ques on No 5: i. Build an FA that accepts only those words that have more than four le ers. ii.
Build an FA that accepts only those words that have fewer than four le ers. iii. Build an FA that
accepts only those words that have exactly four le ers.

i) SOLUTION
In the above diagram, this FSM will accept strings un l q4, at q4 it will have 4 words and at q5
which will be the final state where it will have more than 4 words. A er that every string will be
accepted by it

ii) SOLUTION:

In this diagram, the fsm will accept strings un l the length is under 4 a er that it will go to a trap
state and the string wont be accepted.

iii. Build an FA that accepts only those words that have exactly four le ers.
In this fsm, it will accept string un l it reaches exactly 4 le ers, the state q4 where it will have 4
le ers will be final, if the string con nues then it will go to a trap state and never be accepted.

Ques on No 6: Build an FA that accepts only those words that do not end with ba

SOLUTION:

in the given fsm, as you can see that the q2 state is the only state where it can get the ba string.
Hence except it every state is the state which will not have last two le ers ba. So except q2,
every state is final state
here, q0 is the ini al state.

Ques on No 7: Build an FA that accepts only those words that begin and end with double le er.
SOLUTION:

This DFA shown above will only accept strings that have double le er in the beginning and end.

Ques on No 8: Build an FA that accepts only those words that have an even number of
substrings ab.
Ques on No 9: i. Recall from Chapter 4 the language of all words over the alphabet {a b} that
have both the le er a and the le er b in them, but not necessarily in that order. Build an FA that
accepts this language
ii. Build an FA that accepts the language of all words with only a's or only b's in them. Give a
regular expression for this language.

i)SOLUTION:

in this fsm , it will only accept string which has both le ers a and b whatever the order is . If it
has only a’s or only b’s . the string wont be accepted.

ii) SOLUTION:
REGULAR EXPRESSION:

(aa* + bb*)

You might also like