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

Tutorial 3 Discussion Document - Batch 03

This document discusses finite state automata and provides examples of regular expressions (REs), non-deterministic finite automata (NFAs), and deterministic finite automata (DFAs). It gives tasks to build NFAs and DFAs that accept specific languages over the alphabet {0-9,a,b,c}. The tasks include languages that: contain at least 3 1's; contain the substring 777; do not contain 777; have length 5 or less. It also gives tasks to write REs and build equivalent NFAs for languages where letters are in a specific order or contain certain substrings.

Uploaded by

Anindya Costa
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)
157 views

Tutorial 3 Discussion Document - Batch 03

This document discusses finite state automata and provides examples of regular expressions (REs), non-deterministic finite automata (NFAs), and deterministic finite automata (DFAs). It gives tasks to build NFAs and DFAs that accept specific languages over the alphabet {0-9,a,b,c}. The tasks include languages that: contain at least 3 1's; contain the substring 777; do not contain 777; have length 5 or less. It also gives tasks to write REs and build equivalent NFAs for languages where letters are in a specific order or contain certain substrings.

Uploaded by

Anindya Costa
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/ 5

Tutorial 3 NFA & DFA discussion – Batch 03

3.1 Finite State Automata

Example

Give a regular expression and an equivalent NFA for the language over {a, b} that starts with aa

and contains the substring ba. Convert the NFA you obtained to a DFA.

RE: aa (a U b)* ba (a U b)*

e.g., Valid strings are aaba, aaabbaaa, aaabbabababab

NFA:

a, b a, b

a a b a
q0 q1 q2 q3 q4

DFA: Need to satisfy two conditions:

1) Every state in the DFA should have an outgoing arrow for every input alphabet.
2) A state should not have redundancy or choice for an input alphabet.

DFA: aaabbaaa a b a, b

a a b a
3)
q0 q1 q2 q3 q4
4)

b
b

a, b
1) Build an NFA (separately for each) that accepts the following languages.
a) Strings over the digits 0-9 which contain at least three 1’s.

b) Strings over the digits 0-9 which contain 777 somewhere in the string.
e.g., strings are: 777, 012345677789, 77710, 7777777777, 012377745689077798765 etc.

Please solve this as Assignment 1, Tutorial 3.

c) Strings over the digits 0-9 which do not contain 777 anywhere in the string.
e.g., strings are 0, 1, 2, 3, 7, 07, 70, 77, 1234567890123456, 1237456770129875477.

0-6, 8-9

7 7
q0\ q0
q1 q2

0-6, 8-9

0-6, 8-9

d) Strings over the digits 0-9 which have length 5 or less.


0-9 0-9
0-9 0-9
0-9
q1 q0
q2 q3 q0
q4 q0
q5
q0
2) Obtain a DFA for each of the NFA built in 1) above.

a) Strings over the digits 0-9 which contain at least three 1’s.

0, 2 - 9 0, 2 - 9 0, 2 - 9 0-9

1 1 1
q0 q1 q2 q3

b) Strings over the digits 0-9 which contain 777 somewhere in the string.

Please solve Question 2 b) as part of your Assignment-1, Tutorial 3.

c) Strings over the digits 0-9 which do not contain 777 anywhere in the string.

e.g., strings are 0, 1, 2, 3, 7, 07, 70, 77, 1234567890123456, 1237456770129875477.

0-6, 8-9 0-9

7 7 7
\ q0 q0
q1 q2 q3

0-6, 8-9

0-6, 8-9

d) Strings over the digits 0-9 which have length 5 or less.


3) Give a regular expression for each of the sets given below and build an equivalent NFA.
a) The set of strings over {a, b, c} in which ALL the a’s precede the b’s, which in turn precede the
c’s.
e.g., valid strings are: abc, abbccc, aaaabccc, aaaabbbbcccccc

RE: a+b+c+

a b c

a b c
q0 q1 q2 q3

a, b , c

b) The set of strings over {a, b, c} that begin with a, contain exactly two consecutive b’s and end
with cc.

RE: a (a U c)* bb (a U c)*cc

e.g., valid strings are: abbcc, acabbacacaaccc

Please solve this Question as part of your Assignment-1, Tutorial 3.

c) The set of strings over {a, b, c} that do not contain the substring aa.
Please solve this Question as part of your Assignment-1, Tutorial 3.
For the above question NFA is easy to construct. However, writing the RE would be tricky. Do
not worry. Just try. Otherwise, after the tutorial 3 assignment submission I’ll discuss in class.
You will not lose marks for the RE.

You might also like