15
COURSES ABOUT R THURIMELLA Professor Jeffrey Ullman March 2012 Automata Feedback — Final Exam You have submitted this exam on Mon 18 Jun 2012 11:29:15 PM PDT. You achieved a score of 130.00 out of 170.00. 1. No penalty for wrong answer, so guessing is harmless (compared with leaving blank) 2. All multiple-choice questions (radio buttons) count 5 points. 3. All check-box questions are 1 point per box, or two points per box if the question indicates. 4. You must submit within 3 hours of downloading the exam. Question 1 Examine the following DFA: If the input is 011100101, which edge of the automaton is NOT traversed? Your Answer Score Explanation 5.00 Total 5.00 / 5.00 The states traversed are ABDBDABDAC, and the only edge not traversed is Question 2 Examine the following DFA: If string s is accepted by this DFA, which of the following strings cannot be a suffix of s? Your Answer Score Explanation 111001 5.00 Home Homework Programming Assignments Video Lectures Discussion Forums Help with Subtitles Course Wiki Final Exam Join a Meetup Course Wiki C D C D Exam Feedback https://class.coursera.org/automata/quiz/feedback?submi... 1 of 15 09/07/2012 08:02 PM

Professor Jeffrey Ullman Automata March 2012web.cs.du.edu/~ramki/courses/automata/ullman/finals.pdf · Professor Jeffrey Ullman Automata March 2012 ... Your Answer Score Explanation

Embed Size (px)

Citation preview

Page 1: Professor Jeffrey Ullman Automata March 2012web.cs.du.edu/~ramki/courses/automata/ullman/finals.pdf · Professor Jeffrey Ullman Automata March 2012 ... Your Answer Score Explanation

COURSES ABOUT R THURIMELLA

Professor Jeffrey Ullman

March 2012

Automata

Feedback — Final Exam

You have submitted this exam on Mon 18 Jun 2012 11:29:15 PM PDT. You achieved a

score of 130.00 out of 170.00.

1. No penalty for wrong answer, so guessing is harmless (compared with leaving blank)

2. All multiple-choice questions (radio buttons) count 5 points.

3. All check-box questions are 1 point per box, or two points per box if the question indicates.

4. You must submit within 3 hours of downloading the exam.

Question 1

Examine the following DFA:

If the input is 011100101, which edge of the automaton is NOT traversed?

Your Answer Score Explanation

5.00

Total 5.00 / 5.00

The states traversed are ABDBDABDAC, and the only edge not traversed is

Question 2

Examine the following DFA:

If string s is accepted by this DFA, which of the following strings cannot be a suffix of s?

Your Answer Score Explanation

111001

5.00

Home

Homework

Programming Assignments

Video Lectures

Discussion Forums

Help with Subtitles

Course Wiki

Final Exam

Join a Meetup

Course Wiki

C D

C D

Exam Feedback https://class.coursera.org/automata/quiz/feedback?submi...

1 of 15 09/07/2012 08:02 PM

Page 2: Professor Jeffrey Ullman Automata March 2012web.cs.du.edu/~ramki/courses/automata/ullman/finals.pdf · Professor Jeffrey Ullman Automata March 2012 ... Your Answer Score Explanation

Total 5.00 / 5.00

111001 cannot be the suffix of any string accepted by this DFA. Suppose s=w111001. No matter

what state the DFA reaches after reading w, it will go to state D after reading "111", then go to

state B after reading "00" and finally reaches state C after reading "1".

Question 3

Here is an epsilon-NFA:

Which of the following states is in the closure of A?

Your Answer Score Explanation

N

5.00

Total 5.00 / 5.00

Question 4

Here are seven regular expressions:

(0*+10*)*1.

(0+10)*2.

(0*+10)*3.

(0*+1*)*4.

(0+1)*5.

(0+1*0)*6.

(0+1*)*7.

Determine the language of each of these expressions and partition them into groups of expressions

that define the same language. Then, check all and only the pairs of equivalent expressions.

Your Answer Score Explanation

(0+1)* and (0*+1*)*

1.00

(0+1)* and (0+1*)*

1.00

(0+10)* and (0*+10)*

1.00

(0*+10*)* and (0*+1*)*

0.00

(0+10)* and (0*+1*)*

1.00

(0*+10*)* and (0*+10)*

0.00

Exam Feedback https://class.coursera.org/automata/quiz/feedback?submi...

2 of 15 09/07/2012 08:02 PM

Page 3: Professor Jeffrey Ullman Automata March 2012web.cs.du.edu/~ramki/courses/automata/ullman/finals.pdf · Professor Jeffrey Ullman Automata March 2012 ... Your Answer Score Explanation

(0*+10*)* and (0+10)*

0.00

(0+1)* and (0+10)*

1.00

(0+1)* and (0*+10)*

1.00

(0*+10*)* and (0+1*0)*

1.00

Total 7.00 / 10.00

Expressions 1, 4, 5, and 7 all generate all strings of 0's and 1's. They are thus all equivalent.

Expressions 2 and 3 are equivalent; each generates all strings of 0's and 1's such that every 1 is

followed by a 0. Expression 6 is equivalent to none of the others, since it generates all strings of

0's and 1's that are either empty or end in 0.

Question 5

Which of the following strings is NOT in the Kleene star of the language {011, 10, 110}?

Your Answer Score Explanation

10011101

5.00

Total 5.00 / 5.00

Every string in the language {011, 10, 110}* has to be formed from zero or more uses of the

strings 011, 10, and 110. A string may be used more than once.

Question 6

Check all and only the languages that are regular.

Your Answer Score Explanation

leaves a remainder of 1 when divided by 7 and

leaves a remainder of 4 when divided by 17

0.00

1.00

1.00

1.00

Total 3.00 /

4.00

According to pumping lemma, is not a regular language. is the

language of the DFA with two states to achieve an even number of 0's. is

just strings of non-negative number of 0's, which is the language of a DFA with only one state.

is the language of a DFA with states: state

(p,q) represents that any string reaching this state is .

Question 7

Converting a DFA such as the following:

0n n

0n1n n 0

0m0n n m 0

0n0n n 0

0n1n n 0 0n0n n 0

0m0n n m 0

0n n ≡ 1 mod 7 ∧ n ≡ 4 mod 17 7 17

0k k ≡ p mod 7 ∧ k ≡ q mod 17

Exam Feedback https://class.coursera.org/automata/quiz/feedback?submi...

3 of 15 09/07/2012 08:02 PM

Page 4: Professor Jeffrey Ullman Automata March 2012web.cs.du.edu/~ramki/courses/automata/ullman/finals.pdf · Professor Jeffrey Ullman Automata March 2012 ... Your Answer Score Explanation

to a regular expression requires us to develop regular expressions for limited sets of paths ---

those that take the automaton from one particular state to another particular state, without

passing through some set of states. For the automaton above, determine the language for the

following limitations:

L = the set of path labels that go from A to B without passing through C or D.

Which of the following gives a regular expression for L ?

Your Answer Score Explanation

L = 0*1(00*1)*

5.00

Total 5.00 / 5.00

First, consider paths from A to B that do not go through C. There are two approaches. First, we

can break the path up as going from A to A zero or more times, followed by a jump (on input 1) to

B. Thus, L = (0+10)*1. An alternative view is to say that we must go from A to B the first time,

and then from B to B zero or more times. The first part can be expressed as 0*1, and the second

part as (00*1)*. Note that the latter is an expression for L . The concatenation of the two parts

gives us an expression for L = 0*1(00*1)*.

Question 8

Here is the transition table of a DFA that we shall call M:

0 1

→A B G

B C H

*C D G

*D A H

E F C

F G I

*G H C

*H A D

I E I

Find the minimum-state DFA equivalent to the above. States in the minimum-state DFA are each

the merger of some of the states of M. In the list below, check each set of states of M that forms

one state of the minimum-state DFA.

Your Answer Score Explanation

{C,G}

0.00

{D,H}

0.00

{G,H}

1.00

AB

AB

AB

AB

BB

AB

Exam Feedback https://class.coursera.org/automata/quiz/feedback?submi...

4 of 15 09/07/2012 08:02 PM

Page 5: Professor Jeffrey Ullman Automata March 2012web.cs.du.edu/~ramki/courses/automata/ullman/finals.pdf · Professor Jeffrey Ullman Automata March 2012 ... Your Answer Score Explanation

{D,H,I}

0.00

{A}

0.00

{A,E}

0.00

Total 1.00 / 6.00

First, there are several inaccessible states: E, F, and I. You can verify that there is no path from

start state A to any of these states. These three states are not part of any state of the

minimum-state DFA.

For the remaining six states, here is the table of distinguishabilities:

A

x

B

x x

C

x x x

D

x x x

G

x x x x

H A B C D

We start by noting that accepting states C, D, and H are distinguishable from the other three

states. Next, we can distinguish A, D, and H from B, C, and G, because the former go to

nonaccepting states on input 0, while the latter three go to accepting states. Last, we can

distinguish A from B, because on input 1, A goes to G while B goes to H, and we distinguished G

from H on the previous round.

Question 9

If is a language, and is a symbol, then , the quotient of and , is the set of strings

such that is in : is in . Suppose is regular, which of the following

statements is true?

Your Answer Score Explanation

is always a regular language.

5.00

Total 5.00 / 5.00

We can build a DFA for as such: firstly we get the DFA for : . Then, we copy

all the states and transitions to the DFA for . However, we mark any state as a final

state in if and only if is a final state in . And we have

Question 10

Which of the following pairs of grammars define the same language?

Your Answer Score Explanation

G : S → Sa|a

G : S → SS|aa|a

5.00

Total 5.00 / 5.00

L a L/a L a w

wa L L/a w wa L L

L/a

L/a A L L L A

A ′ L/a sA ′ δ s,a A L A ′ L/a

1

2

Exam Feedback https://class.coursera.org/automata/quiz/feedback?submi...

5 of 15 09/07/2012 08:02 PM

Page 6: Professor Jeffrey Ullman Automata March 2012web.cs.du.edu/~ramki/courses/automata/ullman/finals.pdf · Professor Jeffrey Ullman Automata March 2012 ... Your Answer Score Explanation

S → aS|aa generates strings of a's of length >=2; S → Sa|a and S → SS|aa|a generates strings

of a's of length >=1

Question 11

In this question, each checkbox is worth 2 points.

Here is a context-free grammar G:

S → AB

A → 0A1 | 2

B → 1B | 3A

Which of the following strings are in L(G)? (Check all that are.)

Your Answer Score Explanation

021300211

2.00

002111300211

2.00

00211100211

2.00

0021113002111

2.00

Total 8.00 / 8.00

First, notice that A generates strings of the form 0 21 , where n is 0 or more. Also, B generates

zero or more 1's, followed by one 3, and then something that A can generate. Since S generates

something an A can generate followed by something a B can generate, the strings in L(G) are of

the form 0 21 30 21 , where 0 ≤ n ≤ m and 0 ≤ k.

Question 12

The parse tree below represents a rightmost derivation according to the grammar S → AB, A →

aS|a, B → bA.

Which of the following are right-sentential forms corresponding to this derivation? (Check all that

apply.)

Your Answer Score Explanation

aAbAba

0.00

n n

n m k k

Exam Feedback https://class.coursera.org/automata/quiz/feedback?submi...

6 of 15 09/07/2012 08:02 PM

Page 7: Professor Jeffrey Ullman Automata March 2012web.cs.du.edu/~ramki/courses/automata/ullman/finals.pdf · Professor Jeffrey Ullman Automata March 2012 ... Your Answer Score Explanation

abaAba

1.00

Aba

1.00

aABba

0.00

aaBba

1.00

aSba

0.00

aabAba

1.00

aSB

0.00

Total 4.00 / 8.00

To construct a rightmost derivation from a parse tree, we always replace the rightmost

nonterminal in a right-sentential form. It helps to remember that each symbol of each right-

sentential form corresponds to a node N of the parse tree. When a nonterminal is replaced by a

production body, the introduced symbols correspond to the children of node N, in order from the

left.

Thus, we start with right-sentential form S, where the symbol S corresponds to the root of the

parse tree. At the first step, S is replaced by AB, the children of the root; A corresponds to the left

child of the root, and B to the right child.

Since B is the rightmost nonterminal of AB, it is replaced by the string bA, formed by the labels of

the two children of the right child of the root. The next right-sentential form is thus AbA. We

proceed in this manner, next replacing the second of the two A's. The complete rightmost

derivation is:

S => AB => AbA => Aba => aSba => aABba => aAbAba => aAbaba => aababa

Question 13

In this question, each checkbox is worth 2 points.

The grammar G:

S → SS | a | b

is ambiguous. That means at least some of the strings in its language have more than one

leftmost derivation. However, it may be that some strings in the language have only one

derivation. Check all and only the strings that have exactly two leftmost derivations in G.

Your Answer Score Explanation

bbb

2.00

ab

2.00

aabb

0.00

Total 4.00 / 6.00

A string of length 1 has only one leftmost derivation, e.g., S => a. A string of length 2 has only

one derivation, e.g., S => SS => aS => ab.

However, a string of length 3 has exactly two derivations, e.g., S => SS => SSS => aSS

=> abS => aba and S => SS => aS => aSS => abS => aba. In general, we can

decide whether the first S generates a single terminal or two S's.

On the other hand, strings of length four or more have more than two generations. We can either

start S => SS => SSS => SSSS or S => SS => SSS => aSS => aSSS or S => SS

=> aS => aSS, and there are other options as well.

lm

lm lm lm

lm lm lm

lm lm lm lm lm lm lm

lm lm lm lm lm lm lm lm

lm lm

Exam Feedback https://class.coursera.org/automata/quiz/feedback?submi...

7 of 15 09/07/2012 08:02 PM

Page 8: Professor Jeffrey Ullman Automata March 2012web.cs.du.edu/~ramki/courses/automata/ullman/finals.pdf · Professor Jeffrey Ullman Automata March 2012 ... Your Answer Score Explanation

Question 14

A unit pair (X,Y) for a context-free grammar is a pair where:

X and Y are variables of the grammar.1.

There is a derivation X =>* Y that uses only unit productions (productions with a body that

consists of exactly one occurrence of some variable, and nothing else).

2.

For the following grammar:

S → A | B | 2

A → C0 | D

B → C1 | E

C → D | E | 3

D → E0 | S

E → D1 | S

Identify all the unit pairs. Then, select from the list below all pairs that are NOT unit pairs.

Your Answer Score Explanation

(D,C)

1.00

(A,B)

0.00

(S,C)

1.00

(B,C)

0.00

(C,S)

0.00

(A,C)

0.00

(E,C)

1.00

(C,D)

1.00

Total 4.00 / 8.00

The cycle of unit-productions S → A → D → S says that any pair involving only S, A, and D is a

unit pair. Similarly, the cycle S → B → E → S tells us that any pair involving S, B, and E is a unit

pair. But since S is on both cycles, there are derivations involving only unit productions from any

of S, A, B, D, and E to any of these five variables. Thus, any combination of these five variables

is a unit pair.

Further, the productions C → D | E tells us that any pair (C,X) is a unit pair if X is any of the six

variables. The only pairs that are not unit pairs are (X,C) for X = S, A, B, D, or E.

Question 15

Suppose we execute the Chomsky-normal-form conversion algorithm. Let A → BC0DE be one of

the productions of the given grammar, which has already been freed of ε-productions and unit

productions. Suppose that in our construction, we introduce new variable X to derive a terminal a,

and when we need to split the right side of a production, we use new variables Y , Y ,...

What productions would replace A → BC0DE? Identify these replacing productions from the list

below.

Your Answer Score Explanation

Y → DE

0.00

Y → DY

1.00

a

1 2

3

3 4

Exam Feedback https://class.coursera.org/automata/quiz/feedback?submi...

8 of 15 09/07/2012 08:02 PM

Page 9: Professor Jeffrey Ullman Automata March 2012web.cs.du.edu/~ramki/courses/automata/ullman/finals.pdf · Professor Jeffrey Ullman Automata March 2012 ... Your Answer Score Explanation

A → BY

0.00

Y → X Y

0.00

Y → Y D

1.00

Y → CY

0.00

Y → Y X

1.00

A → BY

1.00

Total 4.00 / 8.00

First, we introduce the production X → 0 for the terminal 0, and replace the given production by

A → BCX DE. Then, since the body has length 5, we introduce 5-2 = 3 new variables, Y , Y ,

and Y , with the productions:

A → BY

Y → CY

Y → X Y

Y → DE

Question 16

Consider the pushdown automaton with the following transition rules:

δ(q,0,Z ) = {(q,XZ )}1.

δ(q,0,X) = {(q,XX)}2.

δ(q,1,X) = {(q,X)}3.

δ(q,ε,X) = {(p,ε)}4.

δ(p,ε,X) = {(p,ε)}5.

The start state is q. For which one of the following inputs can the PDA for the first time enter

state p with the input empty and the stack containing XXXZ [i.e., the ID (p,ε,XXXZ )]?

Your Answer Score Explanation

0001110111

5.00

Total 5.00 / 5.00

When in state q, the PDA adds an X to the stack whenever it consumes a 0. The PDA may

consume a 1 with no change to the stack, but only if the stack has top symbol X. That is, on

inputs beginning with 1 the PDA has no choice of move and can never enter state p. Since

entering state p pops an X from the stack, there must be exactly four 0's in the consumed inputs,

and any number of 1's. In addition, the first input must be 0.

Question 17

If we convert the context-free grammar G:

B → 0B | B1 | 0 | 1

to a pushdown automaton that accepts L(G) by empty stack, using the construction rule

introduced in class, which of the following is NOT a rule of the PDA?

Your Answer Score Explanation

δ(q,ε,B) = {(q,0B), (q,B1), (q,0), (q,1)}

0.00

Total 0.00 / 5.00

1

2 0 3

3 4

1 2

2 3 0

2

0

0 1 2

3

1

1 2

2 0 3

3

0 0

0 0

Exam Feedback https://class.coursera.org/automata/quiz/feedback?submi...

9 of 15 09/07/2012 08:02 PM

Page 10: Professor Jeffrey Ullman Automata March 2012web.cs.du.edu/~ramki/courses/automata/ullman/finals.pdf · Professor Jeffrey Ullman Automata March 2012 ... Your Answer Score Explanation

There is one state, q. The input symbols are 0 and 1, and the stack symbols are {B, 0, 1}. B is the

initial stack symbol. The rules are:

δ(q,ε,B) = {(q,0B), (q,B1), (q,0), (q,1)}

δ(q,0,0) = {(q,ε)}

δ(q,1,1) = {(q,ε)}

Question 18

Suppose one transition rule of some PDA P is δ(q,0,X) = {(p,YZ), (r,XY)}. If we convert PDA P to an

equivalent context-free grammar G in the manner described in class, which of the following is a

production of G derived from this transition rule? You may assume s and t are states of P, as well

as p, q, and r.

Your Answer Score Explanation

[qXp] → 0[rXq][qYp]

5.00

Total 5.00 / 5.00

If m and n are any states of P, then the fact that (p,YZ) is in δ(q,0,X) says that there will be a

production [qXm] → 0[pYn][nZm]. Similarly, the choice (r,XY) says that [qXm] → 0[rXn][nYm] is a

production.

Question 19

A Turing machine M with start state q and accepting state q has the following transition function:

δ(q,a) 0 1 B

q

(q ,0,R) - -

q

- (q ,1,R) (q ,B,R)

q

- - -

Select from the following list the string that M will accept by final state.

Your Answer Score Explanation

01010

5.00

Total 5.00 / 5.00

Firstly, notice that the tape head only moves right. Then, when is in state , it has a

transition only on character 0; when is in state , it has a transition on 1 and go to state ,

or reach the end of input and accept the string. Thus,

Question 20

What is NOT satisfying truth assignment for the boolean formula (-x+ y)(y+ z)? Note: we're using -

for NOT, + for OR, and juxtaposition for AND.

Your Answer Score Explanation

x=true, y=false, z=true

5.00

Total 5.00 / 5.00

0 f

0

1

1

0 f

f

M q0

M q1 q0

L M L 0 10 ∗

Exam Feedback https://class.coursera.org/automata/quiz/feedback?submi...

10 of 15 09/07/2012 08:02 PM

Page 11: Professor Jeffrey Ullman Automata March 2012web.cs.du.edu/~ramki/courses/automata/ullman/finals.pdf · Professor Jeffrey Ullman Automata March 2012 ... Your Answer Score Explanation

To make (-x+ y)(y+ z) true, either y=true, or x=false and z=true.

Question 21

In the table below is an instance of Post's Correspondence Problem

Index First String Second String

1

11 110

2

1010 00

3

010 10

4

10 101

Which statement below is true about this instance?

Your Answer Score Explanation

There are solutions starting with index 4.

5.00

Total 5.00 / 5.00

There are solutions starting with 4, such as 4, 1, 4, 2, 3.

Exam Feedback https://class.coursera.org/automata/quiz/feedback?submi...

11 of 15 09/07/2012 08:02 PM

Page 12: Professor Jeffrey Ullman Automata March 2012web.cs.du.edu/~ramki/courses/automata/ullman/finals.pdf · Professor Jeffrey Ullman Automata March 2012 ... Your Answer Score Explanation

Question 22

A Turing machine M with start state q and accepting state q has the following transition function:

δ(q,a) 0 1 B

q

(q ,B,R) (q ,B,R) -

q

(q ,B,R) - (q ,B,R)

q

- - -

Select from the following list all strings that M will accept by final state.

Your Answer Score Explanation

11000

1.00

1110

1.00

001000

1.00

10100

1.00

0000

1.00

1111

1.00

Total 6.00 / 6.00

Firstly, notice that the tape head only moves right. Then, when is in state , it will read 1 and

stay in until reading 0, when it will go to state ; when is in state , it will accept only

character 0 until the end of string. Thus,

Question 23

In this question, each checkbox is worth 2 points. Suppose there are three languages (i.e.,

problems), of which we know the following:

L1 is in P.1.

L2 is NP-complete.2.

L3 is not in NP.3.

Suppose also that we do not know anything about the resolution of the "P vs. NP" question; for

example, we do not know definitely whether P=NP. Classify each of the following languages as

(a) Definitely in P, (b) Definitely in NP (but perhaps not in P and perhaps not NP-complete) (c)

Definitely NP-complete (d) Definitely not in NP:

L1∪L2.

L1 ∩ L2.

L2cL3, where c is a symbol not in the alphabet of L2 or L3 (i.e., the marked concatenation of L2

and L3, where there is a unique marker symbol between the strings from L2 and L3).

The complement of L3.

Based on your analysis, pick the correct, definitely true statements from the list below.

Your Answer Score Explanation

The complement of L3 is definitely not in P.

2.00

L2cL3 is definitely NP-complete.

2.00

0 f

0

1 0

1

1 f

f

M q0

q0 q1 M q1

L M L 1 ∗ 00 ∗

Exam Feedback https://class.coursera.org/automata/quiz/feedback?submi...

12 of 15 09/07/2012 08:02 PM

Page 13: Professor Jeffrey Ullman Automata March 2012web.cs.du.edu/~ramki/courses/automata/ullman/finals.pdf · Professor Jeffrey Ullman Automata March 2012 ... Your Answer Score Explanation

L1 ∪ L2 is definitely in NP.

2.00

L2cL3 is definitely not in NP.

0.00

L1 ∪ L2 is definitely NP-complete.

2.00

L1 ∩ L2 is definitely in NP.

2.00

L1 ∪ L2 is definitely in P.

2.00

L1 ∩ L2 is definitely in P.

2.00

Total 14.00 / 16.00

Let L = L1 ∪ L2. It is possible that L1 is empty; that is certainly one language in P. If so, then L =

L2, and L is NP-complete. On the other hand, suppose L1 is all strings over the alphabet of L2 ---

another language in P. Then L = L1, a language in P. Since we don't know whether P = NP, we

cannot conclude L is definitely in P and we cannot conclude that L is definitely NP-complete.

On the other hand, we can conclude definitely that L is in NP. A nondeterministic,

polynomial-time algorithm for L starts by applying a polynomial-time algorithm for L1 to its input,

and if the result is negative applies the NP-recognizer for L2 to the same input. It accepts the

input if either recognizer accepts.

The argument for L = L1 ∩ L2 is essentially the same, although now L is in P if L1 is empty and L

is NP-complete if L1 is all strings over the alphabet of L2. Also, the nondeterministic

polynomial-time algorithm for L works by trying the polynomial-time recognizer for L1 first, and

only accepting if that recognizer accepts and the NP-recognizer for L2 also accepts.

Now, consider L = L2cL3. Suppose L had an NP-recognizer. Let x be some string in L2 (since L2

is NP-complete, and we do not know that P = NP, we can be sure L2 is not empty, so x exists).

Then there is a nondeterministic polynomial-time algorithm for L3 that works as follows. Take

input w, and test it for membership in L3 by feeding xcw to the NP-recognizer for L. Respond

exactly as this recognizer responds. Since we know x is in L2, the recognizer for L accepts xcw if

and only if w is in L3. We now have an NP-recognizer for L3, but we were told that L3 is not in

NP. Thus, our assumption that L is in NP must be false.

Last, let L be the complement of L3. If L is in P, then the complement of L, which is L3, is also in

P. But we know L3 is not even in NP. We do not even know that L is in NP; for example, L3 could

be an undecidable problem. On the other hand, L could be NP-complete. For example, the

complement of the problem SAT is not known to be in NP. But it is possible that L3 is the

complement of SAT and therefore L = SAT, a known NP-complete problem.

Question 24

In this question, each checkbox is worth 2 points.

Let us call a problem X "NP-Easy" if it is polynomial-time reducible to some problem Y that is in

NP. Let us denote as "NP-Equivalent", the class of problems that are both NP-Easy and

NP-Hard. Let A,B,C,D and E be problems such that A is NP-Hard, B is NP-Complete, C is

NP-Equivalent, D is NP-Easy and E is in NP. Which of the following statements are TRUE?

Your Answer Score Explanation

If E is in P then so is A.

2.00

If P=NP then A is in P.

2.00

If P=NP then C is in P

0.00

If C is in P then P=NP.

0.00

If C is in P then so is A.

2.00

If P=NP then D is in P.

0.00

If B is in P then so is A.

2.00

Exam Feedback https://class.coursera.org/automata/quiz/feedback?submi...

13 of 15 09/07/2012 08:02 PM

Page 14: Professor Jeffrey Ullman Automata March 2012web.cs.du.edu/~ramki/courses/automata/ullman/finals.pdf · Professor Jeffrey Ullman Automata March 2012 ... Your Answer Score Explanation

If D is in P then so is A.

2.00

Total 10.00 / 16.00

Some key facts we are using include:

1. If a problem A reduces to a problem B, then A is at least as hard as B.

2. Since A is NP-Hard, for every language L in NP, there is a polynomial-time reduction from L to

A.

3. Since C is NP-Easy, it implies that C is reducible in polynomial time to another problem F in

NP. F is reducible in polynomial time to A. So C is polynomial-time reducible to A. A similar

reasoning holds for D.

4. Since A is NP-Hard, every problem in NP reduces to A in polynomial time. If A is in P, all such

problems R can be solved in polynomial time using the algorithm for reducing R to A combined

with the algorithm for A. This would imply that P = NP.

5. We denote a problem X as NP-Easy if it is polynomial-time reducible to some problem Y that is

in NP. Then the fact that Y is in NP, combined with the reduction, implies that X is also in NP.

Moreover, if X is NP-equivalent, then X is also NP-Hard. Hence the notions of NP-Equivalence

and NP-Completeness are the same.

Question 25

The classes of languages P and NP are closed under certain operations, and not closed under

others, just like classes such as the regular languages or context-free languages have closure

properties. Decide whether P and NP are closed under each of the following operations.

Union.1.

Intersection.2.

Intersection with a regular language.3.

Kleene closure (star).4.

Homomorphism.5.

Inverse homomorphism.6.

Then, check each of the statements that are true.

Your Answer Score Explanation

P is not closed under union.

1.00

NP is not closed under intersection.

1.00

P is not closed under homomorphism.

0.00

NP is closed under inverse homomorphism.

0.00

NP is not closed under intersection with a regular

language.

0.00

NP is not closed under homomorphism.

0.00

P is closed under Kleene closure.

1.00

NP is not closed under union.

1.00

P is closed under homomorphism.

1.00

Total 5.00 /

9.00

Both P and NP are closed under each of these operations, except for homomorphism. To see

why neither class is closed under homomorphism, start with a very hard language L, say one that

requires time 2 . Make it easy by appending to each word of length n exactly 2 c's, where c is a

new symbol. That is, let L' = Lc . Then L' is surely in P and NP. But L is h(L'), if h is the

homomorphism that sends c to ε and is the identity on all symbols of L. If P or NP were closed

2

n

2

n

2

2

n

Exam Feedback https://class.coursera.org/automata/quiz/feedback?submi...

14 of 15 09/07/2012 08:02 PM

Page 15: Professor Jeffrey Ullman Automata March 2012web.cs.du.edu/~ramki/courses/automata/ullman/finals.pdf · Professor Jeffrey Ullman Automata March 2012 ... Your Answer Score Explanation

under homomorphism, then L would be in NP, which it is not.

Here are the constructions that show P and NP closed under the other five operations:

L1 ∪ L2: Apply the tests for membership in L1 and then for membership in L2. Accept if either

accepts. If L1 and L2 are in P, then both tests are polynomial, so the entire process is

polynomial. If L1 and L2 are in NP, then there is a nondeterministic polynomial algorithm for

the entire process.

1.

L1 ∩ L2: The argument is the same, but accept only if both tests accept.2.

Intersection with a regular set: The argument is the same as (2), since a regular language is

surely in P and NP.

3.

L*: If L is in NP, guess all the places on the input where strings in L end. Run the

nondeterministic polynomial-time test on each segment. Since there are at most n segments,

the whole process is nondeterministic polynomial. If L is in P, we again must be systematic.

For each pair of input positions i and j, run the polynomial-time test to see whether positions I

through j of the input is in L. If L has a p(n)-time algorithm, then this process takes O(n p(n))

time, a polynomial. Then, use a dynamic programming algorithm, taking O(n ) time, to

determine whether positions i through j can be composed of 1, 2,...,n strings in L. At the end,

we only care about whether positions 1 through n can be composed of some number of

strings in L.

4.

h (L): Any homomorphism h can only expand the length of the string to which it is applied by

a constant factor. To recognize h (L), apply h to the input w, and see whether h(w) is in L. If

there is a polynomial-time, or nondeteministic polynomial-time test for membership in L, this

test will, in the same order of magnitude time complexity tell us whether w is in h (L).

5.

2

3

-1

-1

-1

Exam Feedback https://class.coursera.org/automata/quiz/feedback?submi...

15 of 15 09/07/2012 08:02 PM