Loading in 5 sec....

1. Let A ={r, p, i } and B = { w, o, r, l, d }. What does each of the following (a), (b) and (c) denote? Briefly explain in plain English.PowerPoint Presentation

1. Let A ={r, p, i } and B = { w, o, r, l, d }. What does each of the following (a), (b) and (c) denote? Briefly explain in plain English.

- By
**oshin** - Follow User

- 309 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about 'Key answers for the midterm ' - oshin

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

Midterm (Models of Computation, Spring, 2001)

(Key Answers)

1. Let A ={r, p, i } and B = { w, o, r, l, d }. What does each of the following (a), (b) and (c) denote?

Briefly explain in plain English.

(a) A*B (b) B*AB* (c) (r + p + i)(w + o + r + l + d)* (d) (w + o + r + l + d)*(r + p + i)(d + l + r + o + w)*

Answer:

(a) The set of strings, including the null string (epsilon), over the symbols (i.e., alphabet) {r, p, i} that ends with a symbol in

set {w, o, r, l, d}.

(b) The set of strings over the alphabet {r, p, i, w, o, r, l, d} that include exactly one symbol from {r, p, i}.

Notice that this statement implies the set of strings over alphabet {w, o, r, l, d}, including the null string, followed by a symbol

in {r, p, i} followed by a string over alphabet {w, o, r, l, d}, including the null string.

(c) This is a regular expression which denotes the set of strings which start with a symbol in {r, p, i} followed by a string, over

the alphabet {w, o, r, l, d}, including the null string.

(d) This regular expression denotes the same set of strings expressed by B*AB* .

2. Let L1, L2, and L3 be as shown below, where for a string x, #a(x), #b(x), and #c(x), respectively, mean the number of a’s in x, the number of b’s in x, and the number of c’s in x.

L1 = {a, b, c}* L2 = { x | x {a, b, c}* and #a(x) #b(x) } L3 = { x | x {a, b, c}* and #b(x) = #c(x) }

What will be the result of each of the following set operations? Show your answer with a set property.

(a) (L1 - L2 ) { aibjak | i, j,k 0 } (b) (L1 - L3) { aibjck | i,j,k 0 } (c) (L1 - L2 – L3) { aibjck | i,j,k > 0 }

Answer: (a) { aibjak | i, j, k 0, i+k = j } (b) { aibjck | i, j, k 0, j k } (c) { aibjck | i, j, k 0, i=j k }

3. What is the language generated by each of the following grammars?

Show your answers with a set notation.

(a) S 0S1 | B | C B 0B | 0 C 1C | 1

(b) S AaBb Aa b bBb b Bb c

(c) S De D Da | E Ea E Ee

Answer: (a) { aibj | i, j 0, i j }

(b) {b, bc}

(c ) { }

4. What is the language generated by L-system G = ({a, b, c, d}, h, ab), where h is defined as follows?

h(a) = ac, h(b) = bd, h(c) = c, h(d) = d

Answer: {acibdi | i 0 }

5. Construct a context-free grammar that generates each of the following languages. Notice that part (b) is the set product.

(a) L1 = { aibj | i j 0 } (b) L1{aaa, bbb, ccc} (c) L3= {x | x {a, b}*, and x = xR}

Answer: (a) S aSb | A A aA |

(b) S FE F aFb | A A aA | E aaa | bbb | ccc

Notice that with F the grammar generates language L1.

(c) S aSa | bSb | a | b |

Notice that L3 is different from {xxR | x {a, b}*}, which can be generated by S aSa | bSb |

<header>

<strange>

b

<header>

<body>

<body>

c

<body>

d

1

0

0

A

S

A

1

B

S

C

C

A

B

C

A

0

start

1

0

0

0

1

B

0

1

B

1

1

1

C

B

A

0

6. Construct a context-free grammar which generates the language defined by the following syntax flow graph for <strange>.

Answer: Let <strange>, <header>, and <body> be,

respectively, S, H, and B.

S HB | H H H | b B cBd | cd

7. Construct a syntax flow graph which defines the language {x | x {0, 1}+, and the decimal value of x is divisible by 3 }.

You should briefly describe how you got your answer.

Answer: We first convert the following DFA that accepts the language (see the lecture note) to a regular grammar, and then

transform the grammar to a syntax flow graph.

S 0A | 1B A 0A | 1B |

B 0C | 1A C 0B | 1C

To grammar

DFA:

To syntax flow graph

(0,0,L)

(Y,Y,L)

(0,0,R)

(Y,Y,R)

q2

(Y,Y,R)

(1,Y,L)

q1

q4

(X,X,R)

(0,X,R)

(0,X,R)

q0

(B,B,N)

start

(Y,Y,R)

q3

q5

8. We learned that the deterministic TM shown below recognizes the language {0i1i | i > 0 }. Is it possible for a deterministic LBA recognizes this language? If your answer is negative, explain why. If your answer is positive, show a state transition graph of your DLBA.

Change to ( ], ], N )

Answer: Yes it is possible. Since the input is bounded by the boundary markers [

and ], we can simply modify the above TM state transition graph to a DLBA state

transition graph by changing the edge label (B, B, N) entering the accepting state

5 to ( ], ], N ). Notice that as in TM we assume that the machine is reading the left-

most input symbol.

(a, A/ aA)

(a, a/ aa)

(b, b/ bb )

(b, Z0/ bZ0)

(b, a/)

(b, A/ )

(a, b/ )

(a, Z0/AZ0)

(b, a/ )

(b, A/ )

(a, b/ )

(a, b/ )

(b, Z0/Z0)

(a, Z0/ Z0)

(a, Z0/ Z0)

(a, b/ )

(b, b/bb)

(a, Z0/ Z0)

start

Notice that the language includes strings starting with symbol b, which are recognized by the transitions going along the lower part of the transition graph.

9. Construct a DPDA which recognizes the language L= {aibjak | i + k > j > 0 }.

Answer:

start

a, b

1

2

3

4

a

a, b

a

start

a, b

1

2

3

4

a, b

a, b

a, b

a

a, b

start

1

2

3

4

10. Eliminate epsilon-transitions from the FA shown below without changing the number of states and the language accepted by the automaton.

- Answer: Transition analysis
- Let x = *a* and y = *a*. Then
- (1, x) = {1, 2, 3, 4}, (1, y) = {3, 4}
- (2, x) = {3, 4}, (2, y) = {3, 4}
- (3, x) = (3, y) =
(4, x) = (4, y) =

11. Let L be the language accepted by the automaton in problem 10 above. Show an FA which recognizes the language L*.

** Since L = {a}*{a, b}, we have L* = {a, b}*.

Hence, the FA shown below can be a simple

solution for this problem .

Change edge labels to regular expression, and

eliminate state A.

a, b, c

a+b+c

B

a

b

B

a

start

b

b

S

start

b

S

c

C

a

D

c

C

A

D

a

ca

a

Eliminate

state B:

(a+b+c)+(ab(cb)*ca)

b(cb)*a

ab(cb)*a

a+b+c

start

S

D

cb

b(cb)*ca

ab

start

b

S

C

D

ca

a

12. Construct a regular expression which denotes the language accepted by the following FA. Notice that thick circles are accepting states.

Let r11 = (a+b+c)+(ab(cb)*ca)

r12 = ab(cb)*a

r22 = b(cb)*a

r2 1 = b(cb)*ca

Then, rS = [r11 + r12 (r22 )*r2 1 ]*

rD = [(r11)*r12 [r22 + r2 1(r11)* r12]*

Answer: r = rS + rD

Eliminate

state C;

Read off regular expression

** Since the language accepted by the automaton is {a, b, c}*, the answer can be simply (a + b + c)*.

13. Construct a regular grammar that produces the same language accepted by the FA in problem 12 above.

Answer: Using the state labels on the state transition graph in problem 11 above, we get the following.

S aS | bS | cS | aB | A aA | B B bC C cA | aD D bC |

a

a, b

a

a

b

start

{1}

{1,2,3}

{2,3,4}

{3}

{2,4}

b

a

b

a

start

a, b

b

1

2

3

4

a

14. Using the technique discussed in the class, convert the following NFA to a DFA which accepts the same language.

Answer:

15. The other day, local environmentalists formed a long human chain, everyone holding hand to hand, to block dumping drums of chemical waste to the river. The organization’s both vice chairwoman and vice chairman were each positioned at each end of the chain throughout the demonstration.

A journalist who covered this event reported that interestingly the number of joined hands between different genders was odd throughout the event, with no regard to the length of the chain (i.e., the number of activists involved). His report ended with the following comment;

“It was so oddly odd that somebody should further investigate the phenomenon.”

Question: As a student attending the course Models of Computation, prove that the journalist’s observation is correct and natural.

Answer: Let the human chain be transformed to a sequence of nodes with all females labeled by 1 and males by 2. Then we can translate the sequence of nodes as a problem instance of the Sperner’s lemma that we studied in the class, if we consider each pair of joined hands between different genders as a good block. According to the Sperner’s lemma the number of good blocks (i.e., the number of joined hand-pairs) is always odd. So the reporter’s observation is correct and natural. (Refer the lecture note for the proof of Sperner’s lemma by induction.)

16. Using the proof by induction technique show that for every regular expression, we can construct an FA which recognizes the language that is expressed by the expression.

Answer: We can simply copy the proof in the lecture note slide numbers 88 through 89, which is actually a proof by induction of the given problem. (Key answer is omitted.)

Download Presentation

Connecting to Server..