[go: up one dir, main page]

100% found this document useful (1 vote)
4K views25 pages

Practice Problems DFA

The document provides examples of constructing deterministic finite automata (DFAs) for various languages over different alphabets. For each example, it gives the regular expression, outlines the steps to construct the DFA, and provides the solution DFA diagram.

Uploaded by

Syed Ali Hashmi
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)
4K views25 pages

Practice Problems DFA

The document provides examples of constructing deterministic finite automata (DFAs) for various languages over different alphabets. For each example, it gives the regular expression, outlines the steps to construct the DFA, and provides the solution DFA diagram.

Uploaded by

Syed Ali Hashmi
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/ 25

Example 1: Draw a DFA for the language accepting strings ending with ‘0’

over input alphabets ∑={0, 1} ?


Solution:

Example 2: Draw a DFA for the language accepting strings ending with ‘01’
over input alphabets ∑={0, 1} ?
Solution:

Example 3: Draw a DFA for the language accepting strings ending with ‘00’
over input alphabets ∑={0, 1} ?
Solution:
Example 4: Draw a DFA for the language accepting strings ending with ‘011’
over input alphabets ∑ = {0, 1} ?
Solution:

Example 5: Draw a DFA for the language accepting strings ending with ‘0110’
over input alphabets ∑ = {0, 1} ?
Solution:

Example 6: Draw a DFA for the language accepting strings ending with ‘0011’
over input alphabets ∑ = {0, 1} ?
Solution:
Example 7: Draw a DFA for the language accepting strings with ‘0’ only over
input alphabets ∑={0, 1} ?
Solution:

Example 8: Draw a DFA for the language accepting strings with ‘0’ and ‘1’
only over input alphabets ∑={0, 1} ?
Solution:
Example 9: Draw a DFA for the language accepting strings starting with ‘0’
over input alphabets ∑={0, 1} ?
Solution:

Example 10: Draw a DFA for the language accepting strings starting with ‘01’
over input alphabets ∑={0, 1} ?
Solution:
Example 11: Draw a DFA for the language accepting strings starting with ‘00’
over input alphabets ∑={0, 1} ?
Solution:

Example 12: Draw a DFA for the language accepting strings starting with ‘011’
over input alphabets ∑ = {0, 1} ?
Solution:
Example 13: Draw a DFA for the language accepting strings starting with
‘0110’ over input alphabets ∑ = {0, 1} ?
Solution:

Example 14: Draw a DFA for the language accepting strings starting with
‘0011’ over input alphabets ∑ = {0, 1} ?
Solution:

Example 15: Draw a DFA for the language accepting strings starting with ‘00’
or ’11’ over input alphabets ∑ = {0, 1} ?
Solution:
Example 16: Draw a DFA for the language accepting strings without substring
‘00’ over input alphabets ∑ = {0, 1} ?
Solution:

Example 17: Draw a DFA for the language accepting even binary numbers
strings over input alphabets ∑ = {0, 1} ?
Soluntion:
Example 18: Draw a DFA for the language accepting odd binary numbers
strings over input alphabets ∑ = {0, 1} ?
Solution:

Example 19: Draw a DFA for the language accepting odd or even binary
numbers strings over input alphabets ∑ = {0, 1} ?
Solution:
Example 20: Draw a DFA for the language accepting strings containg even
number of total zeros over input alphabets ∑ = {0, 1} ?
Solution:

Example 21: Draw a DFA for the language accepting strings starting and
ending with different characters over input alphabets ∑ = {0, 1} ?
Soluiton:
Example 22: Draw a DFA for the language accepting strings starting and
ending with same character over input alphabets ∑ = {0, 1} ?
Solution:

Example 23: Draw a DFA for the language accepting strings starting and
ending with ‘0’ always over input alphabets ∑ = {0, 1} ?
Solution:

Example 24: Draw a DFA for the language accepting strings containing three
consecutives ‘0’ always over input alphabets ∑ = {0, 1} ?
Solution:

Example 25: Draw a DFA for the language accepting strings such that each ‘0’
is immediately preceded and followed by ‘1’ over input alphabets ∑ = {0, 1} ?
Solution:
Example 26: Draw a DFA for the language accepting strings containing at
most two ‘0’ over input alphabets ∑ = {0, 1} ?
Solution:

Example 27: Draw a DFA for the language accepting strings containing at
least two ‘0’ over input alphabets ∑ = {0, 1} ?
Solution:

Example 28: Draw a DFA for the language accepting strings containing
exactly two ‘0’ over input alphabets ∑ = {0, 1} ?
Solution:
Example 29: Draw a DFA for the language accepting strings with ‘011’ as
substring over input alphabets ∑ = {0, 1} ?
Solution:

Example 30: Draw a DFA for the language accepting strings ending in
either ’01’, or ’10’ over input alphabets ∑ = {0, 1} ?
Solution:
Example 31: Draw a DFA for the language accepting strings containing ’01’,
or ’10’ as substring over input alphabets ∑ = {0, 1} ?
Solution:

Example 32: Draw DFA that accepts any string which ends with 1 or it ends
with an even number of 0’s following the last 1. Alphabets are {0,1}.
Solution:
Example 33: Construct DFA accepting set of all strings containing even no. of
a’s and even no. of b’s over input alphabet {a,b}.
Solution:

Example 34: Give DFA accepting the language over alphabet {0,1} such that
all strings of 0 and 1 ending in 101.
Solution:
Example 35: Construct DFA for anb | n>=0.
Solution:

Example 36: construct DFA for binary integer divisible by 3 ?


Solution:

Example 37: Draw a DFA for the language accepting strings containing
neither ’00’, nor ’11’ as substring over input alphabets ∑ = {0, 1} ?
Solution:
Problem-01:

Draw a DFA for the language accepting strings starting with ‘ab’ over input alphabets ∑ =
{a, b}

Solution-

Regular expression for the given language = ab(a + b)*

Step-01:

 All strings of the language starts with substring “ab”.


 So, length of substring = 2.

Thus, Minimum number of states required in the DFA = 2 + 2 = 4.


It suggests that minimized DFA will have 4 states.

Step-02:
We will construct DFA for the following strings-
 ab
 aba
 abab

Step-03:

The required DFA is-

Problem-02:

Draw a DFA for the language accepting strings starting with ‘a’ over input alphabets ∑ = {a,
b}

Solution-

Regular expression for the given language = a(a + b)*


Step-01:

 All strings of the language starts with substring “a”.


 So, length of substring = 1.

Thus, Minimum number of states required in the DFA = 1 + 2 = 3.


It suggests that minimized DFA will have 3 states.

Step-02:

We will construct DFA for the following strings-


 a
 aa

Step-03:

The required DFA is-

Problem-03:
Draw a DFA for the language accepting strings starting with ‘101’ over input alphabets ∑ =
{0, 1}

Solution-

Regular expression for the given language = 101(0 + 1)*

Step-01:

 All strings of the language starts with substring “101”.


 So, length of substring = 3.

Thus, Minimum number of states required in the DFA = 3 + 2 = 5.


It suggests that minimized DFA will have 5 states.

Step-02:

We will construct DFA for the following strings-


 101
 1011
 10110
 101101

Step-03:

The required DFA is-


Problem-04:

Draw a DFA that accepts a language L over input alphabets ∑ = {0, 1} such that L is the set
of all strings starting with ’00’.

Solution-

Regular expression for the given language = 00(0 + 1)*

Step-01:

 All strings of the language starts with substring “00”.


 So, length of substring = 2.

Thus, Minimum number of states required in the DFA = 2 + 2 = 4.


It suggests that minimized DFA will have 4 states.
Step-02:

We will construct DFA for the following strings-


 00
 000
 00000

Step-03:

The required DFA is-

Problem-05:

Construct a DFA that accepts a language L over input alphabets ∑ = {a, b} such that L is
the set of all strings starting with ‘aa’ or ‘bb’.

Solution-
Regular expression for the given language = (aa + bb)(a + b)*

Step-01:

Minimum number of states required in the DFA = 5.


It suggests that minimized DFA will have 5 states.

Step-02:

We will construct DFA for the following strings-


 aa
 aaa
 aaaa
 bb
 bbb
 bbbb

Step-03:

The required DFA is-


Problem-06:

Construct a DFA that accepts a language L over input alphabets ∑ = {a, b} such that L is
the set of all strings starting with ‘aba’.

Solution-

Regular expression for the given language = aba(a + b)*

Step-01:

 All strings of the language starts with substring “aba”.


 So, length of substring = 3.

Thus, Minimum number of states required in the DFA = 3 + 2 = 5.


It suggests that minimized DFA will have 5 states.

Step-02:

We will construct DFA for the following strings-


 aba
 abaa
 abaab
 abaaba

Step-03:

The required DFA is-

You might also like