100% found this document useful (1 vote)
299 views

Hwsol 3

This document contains the solutions to homework problems from an introduction to the theory of computation course. It includes regular expressions for various languages, proofs that any NFA can be converted to an equivalent one with a single accept state, and examples of strings that are members or non-members of specific regular languages.

Uploaded by

Averil-Chan
Copyright
© Attribution Non-Commercial (BY-NC)
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)
299 views

Hwsol 3

This document contains the solutions to homework problems from an introduction to the theory of computation course. It includes regular expressions for various languages, proofs that any NFA can be converted to an equivalent one with a single accept state, and examples of strings that are members or non-members of specific regular languages.

Uploaded by

Averil-Chan
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 8

CSE 396

Introduction to the Theory of Computation

Fall 2008

Homework Solution - Set 3


Due: Friday 9/19/08

1. Textbook, Page 83, Exercise 1.4. (a) i. {w | w has at least three as}
b b a b a a,b a

A ii. {w | w has at least two bs}

a b

a,b b

iii. {w | w has at least three as and at least two bs} 1A


b a

1B
b

1C
b

1D
b

2A
b

2B
b

2C
b

2D
b

3A
b

3B
b

3C
b

3D

a,b

(b)

i. {w | w has exactly two as}


b b a b a a,b a

A ii. {w | w has at least two bs}

a b

a,b b

iii. {w | w has exactly two as and at least two bs} 1A


b a

1B
b

1C
b

1D
b

2A
b

2B
b

2C
b

2D
b

3A
b

3B
b

3C
b

3D

a,b

(c)

i. {w | w has an even number of as}


b a b

1
a

ii. {w | w has one or two bs}


a a b a b a,b

iii. {w | w has an even number of as and one or two bs} 1A


a a b a b

1B
a

b a b

1C
a

b a b

1D
a

2A (d)

2B

2C

2D

i. {w | w has an even number of as}


b a b

1
a

ii. {w | each a in w is followed by at least one b}


b a a,b

A
b

iii. {w | w has an even number of as and each a is followed by at least one b}


b b b a a

1A

1B
a a a

1C
a

2A
b

2B

2C
b

(e)

i. {w | w starts with an a}
a,b a,b

1 ii. {w | w has at most one b}

a b

a,b b

iii. {w | w starts with an a and has at most one b}


a a b b a,b b b

1A

1B

1C
b

2A
a b a

2B
a b a,b

2C
a

3A
a

3B

3C

(f)

i. {w | w has an odd number of as}


b a b

1
a

ii. {w | w ends with a b}


3

A
a

iii. {w | w has an odd number of as and ends with a b} 1A


a a b

1B
a a b

2A i. {w | w has even length}

2B
b

(g)

a,b

A
a,b

ii. {w | w has an odd number of as}


b a b

1
a

iii. {w | w has even length and an odd number of as}


b

1A
b a a b a

1B
a

2B
b

2A

2. Textbook, Page 84, Exercise 1.7. (a) The language {w | w ends with 00} with three states
0,1

(b) The language of Exercise 1.6c with ve states


4

0,1

0,1

(c) The language of Exercise 1.6l with six states


1 0 1

2
0 0

3
0 1 0 1

4 (d) The language {0} with two states 1 (e) The language 0 1 0+ with three states
0

0 0

(f) The language 1 (001+ ) with three states 2


0 0

1
1

(g) The language {} with one state 1 (h) The language 0 with one state

3. Textbook, Page 85, Exercise 1.11. Prove that every NFA can be converted to an equivalent one that has a single accept state. As discussed in class, create a single new nal state. Create -edges from the original nal states to this new nal state. Make the original nal states non-nal. If the processing of an input word completes in one of the original nal states, the new nal state is immediately accessible without any additional symbols. Furthermore, the only way to access the new nal state is if the processing completes in one of the original nal states. Hence, all words previously accepted will remain accepted and no additional words will be accepted, meaning the two machines accept the same language and are therefore equivalent. 4. Textbook, Page 86, Exercise 1.18. Give regular expressions generating the languages of Exercise 1.6. (a) {w | w begins with a 1 and ends with a 0} 1 0 (b) {w | w contains at least three 1s} 1 1 1 (c) {w | w contains the substring 0101, i.e., w = x0101y for some x and y } 0101 (d) {w | w has length at least 3 and its third symbol is a 0} 0 (e) {w | w starts with 0 and has odd length, or starts with 1 and has even length} (0 1)() (f) {w | w doesnt contain the substring 110}

0 (10+ ) 1 (g) {w | the length of w is at most 5} ( )5 (h) {w | w is any string except 11 and 111} 0 10 0 10 110 3 + (i) {w | every odd position of w is a 1} (1) ( 1) (j) {w | w contains at least two 0s and at most one 1} 00+ 100+ 0+ 10+ 00+ 1 (k) {, 0} 0 (l) {w | w contains an even number of 0s, or contains exactly two 1s} 1 (01 01 ) 0 10 10 (m) The empty set (n) All strings except the empty string + 5. Textbook, Page 86, Exercise 1.20. (a) a b Members: ab, abb Not members: ba, bba
7

(b) a(ba) b Members: ab, ababab Not members: aba, bab (c) a b Members: aaa, bbb Not members: aabb, bbaa (d) (aaa) Members: aaa, aaaaaa Not members: a, aaaa (e) a b a Members: aba, bbaaabaabb Not members: a, b (f) aba bab Members: aba, bab Not members: ababab, ba (g) ( a)b Members: b, ab Not members: a, ba (h) (a ba bb) Members: a, bbab Not members: b,

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy