0% found this document useful (0 votes)
75 views7 pages

CMPS346-Tutorial 3 - Solution

This tutorial document provides practice problems for constructing DFAs and NFAs that recognize various formal languages. It includes 8 parts asking to construct state diagrams for NFAs that recognize specific languages defined over different alphabets. It also asks to show that a particular language L, defined by comparing binary numbers represented as strings, is regular.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views7 pages

CMPS346-Tutorial 3 - Solution

This tutorial document provides practice problems for constructing DFAs and NFAs that recognize various formal languages. It includes 8 parts asking to construct state diagrams for NFAs that recognize specific languages defined over different alphabets. It also asks to show that a particular language L, defined by comparing binary numbers represented as strings, is regular.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Theory of Computations (CMPS 346)

Tutorial #3

1. Each of the following languages is the intersection of two simpler


languages. In each part, construct DFAs for the simpler languages, and
then combine them using the construction discussed in the lecture to give
the state diagram of a DFA for the language given.

a. L1={ w | w  {a, b}*, w has at least three a’s or at least two b’s}
b. L2={ w | w  {0, 1}*, w ends with 01 or has even number of 1’s}
Answer
a.
b. L2={ w | w  {0, 1}*, w ends with 01 and has even number of 1’s}
L2=L2’ ∩ L2’’ where:
L2’={ w | w  {0, 1}*, w ends with 01}
L2’’={ w | w  {0, 1}*, w has even number of 1’s}


Q1={q0,q1,q2}
∑={0,1}
Ծ1 0 1
q0 q1 q0
q1 q1 q2
q2 q1 q0

q0 is the start state


F1={q2}


Q2={s0,s1}
∑={0,1}
Ծ2 0 1
s0 s0 s1
s1 s1 s0

s0 is the start state


F2={s0}


Q={(q0,s0) , (q0,s1) , (q1,s0) , (q1,s1) , (q2,s0), (q2,s1) }
∑={0,1}
Ծ 0 1
(q0,s0) (q1,s0) (q0,s1)
(q0,s1) (q1,s1) (q0,s0)
(q1,s0) (q1,s0) (q2,s1)
(q1,s1) (q1,s1) (q2,s0)
(q2,s0) (q1,s0) (q0,s0)
(q2,s1) (q1,s1) (q0,s0)

(q0,s0) is the start state


F={(q2,s0)}
2. Give state diagrams of NFAs recognizing each of the following languages.

a. L1= {w| w ends with one of 0110, 010, and 00 } with three states Σ
={0,1}

b. L2={w| w contains the substring ababb (i.e., w = xababby for some


x and y)} Σ ={a,b}

c. L3= {w| w contains odd number of 0’s or the number of 1’s is not
multiple of 3} Σ ={0,1}

d. L4= {bna | n≥1} Σ ={a, b}


e. L5= {w| in w the third symbol from the right end is '0' } Σ ={0,1}

f. L6= {w| w contains an even number of 0s, or contains exactly two


1s} Σ ={0,1}

g. L7= {w| the first and last characters in w are the same} Σ ={0,1}

h. L8= {w| w end in 010 and have 011 somewhere preceding, or end in
101 and have 100 somewhere preceding}

3. Let

Σ=¿ ¿
Consider each row to be a binary number and let
L= {w  * | the top row is a larger binary number than the bottom row}

[0¿]¿¿¿ [0¿]¿¿¿
E.g., ¿ , but ¿ . Show that L is regular.

Answer:

You might also like