100% found this document useful (1 vote)
482 views5 pages

Automata Theory Midterm Exam

This document contains a midterm exam for a formal languages and automata course. It includes 5 questions about finite automata, regular expressions, and pumping lemmas. For question 5, the language of strings with an equal number of 0's and 1's is shown to be non-regular using the pumping lemma. The bonus question asks about a language with at least 3 a's and at most 4 b's, which is shown to be regular with an NFA that has states for each combination of a's and b's.

Uploaded by

Fırat Can
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)
482 views5 pages

Automata Theory Midterm Exam

This document contains a midterm exam for a formal languages and automata course. It includes 5 questions about finite automata, regular expressions, and pumping lemmas. For question 5, the language of strings with an equal number of 0's and 1's is shown to be non-regular using the pumping lemma. The bonus question asks about a language with at least 3 a's and at most 4 b's, which is shown to be regular with an NFA that has states for each combination of a's and b's.

Uploaded by

Fırat Can
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

Çankaya University

Department of Mathematics
2021 - 2022 Fall Semester

CENG 491 - Formal Languages and Automata


First Midterm Examination

1) Find a DFA that recognizes the language L over Σ = {0, 1}:


Strings in L contain odd number of 0’s and odd number of 1’s.

2) Find an NFA that recognizes the language L over Σ = {a, b}:


Strings in L are of length at least 4. Each string ends with abab or bbb.

3) Consider the language given by the following regular expression over Σ = {a, b, c}:
∗
aca∗ a∗ ba∗ ba∗ ca

Describe this language verbally.

4) Find a regular expression equivalent to the language over Σ = {a, b, c} recognized by the following NFA:

b b

a b c

ε
5) Consider the language L over Σ = {0, 1} composed of strings of the type wwR where wR is the reverse
of a string. For example, 10011R = 11001.
Some examples in L are:

1001, 111111, 101101, 00100100, . . .

ˆ If L is regular, find a regular expression for it.

ˆ If L is not regular, prove this using pumping lemma.

Bonus) Consider the following language over Σ = {a, b}:


Strings contain at least three a’s and at most four b’s.

ˆ If it is regular, find an NFA for it.

ˆ If it is not regular, prove this using pumping lemma.


ANSWERS

1)

1 1 1 1

2)

a b a
a, b ε b

ε b

a, b b b

3)

ˆ Strings start with ac and end with ca.

ˆ Strings contain exactly two c’s.

ˆ Number of b’s is even.


4) After eliminating some states, we can obtain:

(ac∗ b ∪ ε)bb

(ac∗ b ∪ ε)(b ∪ c)

Then, the equivalent regular expression is:


 ∗ ∗
(ac b ∪ ε)bb (ac∗ b ∪ ε)(b ∪ c)

or equivalently:
 ∗ ∗
ac bbb ∪ bb (ac∗ bb ∪ ac∗ bc ∪ b ∪ c)

An alternative order of eliminating states give:

bb(ac∗ b ∪ ε)

ac∗ b ∪ ε b∪c

Then, the equivalent regular expression is:


∗
ac∗ b ∪ ε bb(ac∗ b ∪ ε) (b ∪ c)


5) Assume L is regular, let the pumping let be p. Consider the test string

s = 0p 110p

Let’s try to find substrings x, y, z such that s = xyz.


By pumping lemma, we know that |xy| 6 p. Then, y is made of 0’s only in other words y = 0k , 1 6 k 6 p.
But in that case

xyyz = 0p+k 110p ∈


/L

This string cannot be pumped. Therefore, by pumping lemma this language is NOT regular.
Bonus) This language is regular. The following NFA recognizes it:

a a a
a

b b b b

a a a
a

b b b b

a a a
a

b b b b

a a a
a

b b b b

a a a
a

You might also like