Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Assignment 1 (60 points)

1 (10 points) The formal description of a DFA M is ({q1 , q2 , q3 , q4 , q5 }, {u, d}, δ, q3 , {q3 }),
where δ is given by the following table. Let L(M ) be the language of this machine M .
Answer the following questions:
u d
q1 q1 q2
q2 q1 q3
q3 q2 q4
q4 q3 q5
q5 q4 q5

(a) (8 points) Give the state diagram of the above machine


(b) (1 point) Give an example of a string that is a member of L(M )
(c) (1 point) Give an example of a string that is NOT a member of L(M )

2 (10 points) Let Σ = {0, 1} and let v(w) be the value of w in decimal where w is a
string of unsigned binary. For examples, v(0010) = 2 and v(011010) = 26. Note that
v(ε) is undefined. Let

A = {w | w such that 2 ≤ v(w) ≤ 5}.

For example,
• 0100 – accept since v(0100) = 4,
• 0000110 – reject since v(0000110) = 6,
• 1101 – reject since v(1101) = 13 and
• 000000011 – accept since v(000000011) = 3.
Create a state diagram of a machine that recognizes A.
3 (10 points) Let Σ = {0, 1}. Give state diagrams of a DFA recognizing the languages:
{w | w begins with a 1 and ends with a 0}

4 (10 points) Let Σ = {a, b}. Consider the language


A = {w | w has an even number of a’s and one or two b’s}
Note that the languages A is the intersection of two simpler languages, B and C. In
other words, A = B ∩ C. Give state diagrams of DFAs B and C, then combine them
using the construction discussed in class to get the state diagram of the language A.
5 (20 points) Each of the following languages is the complement of a simpler language.
In each part, construct a DFA for the simpler language, then use it to give the state
diagram of a DFA for the language given. In all parts, Σ = {a, b}.
a. {w | w contains neither the substrings ab nor ba}
b. {w | w is any string that doesn’t contain exactly two a’s}

CS 1502 — Formal Methods in Computer Science Page 1

You might also like