CSE 3315 - Theoretical Concepts Homework 6: P and NP

CSE 3315 - Theoretical Concepts
Homework 6- Solution - Fall 2000 Due Date: Dec. 6 2000, 5:30 pm

This algorithm makes iterations (one for each in ). In each iteration it removes one symbol from the first number string and makes a copy of the second number string. This requires moving the read head to the beginning of the input string and then moving it across once. The complexity of , making the total complexity of the algorithm since . each iteration is thus b) Binary subtraction can be solved in a way analogous to binary addition. Using a three-tape Turing machine first copies the second number to tape and adds ’s to the shorter of the numbers to make them the same length. Then, starting with the least significant bit, subtraction is performed bitwise with the carry bit represented in the state of the Turing machine. Assuming state represents the presence of no carry bit and represents the state in which there is a carry bit, subtraction is performed as follows: 
# " ¥ ¡ " ¡ &)# ( $ %# ' " &¡ $ %#    ! ¦    ¨   § ¢ ¡ ¡   ¨  ©§ ¦

For each bit this subtraction requires a constant number of time steps. The initial copying of the second number requires steps. Therefore, the overall algorithm has complexity and is thus polynomial. 
 ¨  §   ¨  ©§

c 2000 Manfred Huber

¥

¤ £¡

¢ £¡

¡

¡

¡

4

4

"

"

"

"

¡

¡

¡

¡

4

4

"

"

"

¡ &)# (

¡ &)# (

¡

4 &# $

4

" 1)# (

" 0# 2

"

"

¡

2 #

2 #

2 # 

#

'

'

'

'

'

'

'

'

'

¡

¡

¡

¡

'

'

" &¡

"

"

¡

¡

' 03# (

'52%# 

" 0%# $

"

"

"

$ %#

$ #   

#

#

#

#

6

 

1.

a) Unary multiplication can be performed by means of successive addition. The following two-tape Turing machine does this in polynomial time: 1. Check if the first number string (initially ) is empty. a) If it is empty the multiplication is finished and the Turing machine halts. 2. Erase the first from the first number string. 3. Append a copy of the second number string ( ) to the string on tape . 4. Go to step 1.

Page 1

This procedure has to be performed at times. This takes time . To find out if the graph is connected it is sufficient to check if all nodes are reachable from a given start node (since the graph is undirected this implies that there is a path from every node to every other node). 4. To show that a given sentence is satisfiable it is sufficient to show that one of the conjunctive terms to be not satisfiable it has to contain is satisfiable. A sentence of d) Sentences in disjunctive normal form are of the form length has fewer than conjunctive terms. . a two-tape Turing machine can be used to execute the following algorithm. the sentence is not satisfiable. a) If it does not. The overall complexity is thus . the overall complexity of the algorithm is and thus polynomial. To test satisfiability we can thus use the following algorithm: 1. b) Otherwise. 1. To determine this. add it to the list on tape . If there are no more conjunctive terms. check if the vertex at the other end of the edge is already on tape . each of which contains fewer than propositions. Go to the first conjunctive term.Theoretical Concepts Homework 6: P and NP c) The transition table of an indirected graph contains a list of all vertices and edges of the graph. go to the next conjunctive term and repeat step 2. 2. the sentence is satisfiable. Go to the next vertex in the list on tape and repeat until no new vertices are added to the list on tape (this list now contains all vertices that can be reached from the first vertex). Check if the list on tape contains all vertices of the graph. Since there are at most vertices. To check for a contradictory pair of propositions in a conjunctive term requires to check the whole term once for each proposition. most   ¨  § 2    ¨   §    9 GE 9    777 S 777 C777 C777 ¨ S 777 C H 9 E C A 9 QQPTRQQWVQQPQQQDUTRQQP)IGFDB@¨ H 9 bGE 777 C Y 9 C A 9 RQQ©a`X)B@¨ H I9         ©§   ¨ 2   ¨  §       ¨   § ¥ ¥ 7 8¥ ¡ ¥ ¥ ¥ ¥ 6 c 2000 Manfred Huber Page 2 . Checking if all vertices are in the list takes steps. If it is not. Copy the first vertex from the transition table on tape to tape . a literal and its negation ). For a conjunctive terms of the form a contradiction (i. 3. Check if the conjunctive term contains a pair of literals of the form and .CSE 3315 . Finding all vertices that are directly connected to a given vertex and adding them to the list on the second tape takes time steps. For all edges that are connected to the the selected vertex.e. 2.

Multiplication of 2 integers of size and has complexity (for both unary and binary representations . . then is the inverse modulo of .e.a or the example in class). This requires to go over all vertices in the transition table and can be performed in steps.Theoretical Concepts Homework 6: P and NP   c 6 b) For this problem. The length of each of these have to be smaller than (if numbers is thus less than . This again requires checking every edge in the cycle (at most ) against all the transition table. To verify that this is a correct solution to the problem the algorithm then checks if the number of vertices in the cycle is exactly half the number of vertices in the graph. Comparing the result with the input is . c) A cycle can be written as a sequence of vertices that starts and ends with the same vertex and that does not include any other vertex more than once. The length of the result is less than and so on. both of which is an inverse. the overall algorithm is nondeterministic polynomial time. Addition takes is therefore Since the nondeterministic generation of a solution and the verification are both polynomial time on a nondeterministic Turing machine. To generate a cycle the algorithm thus nondeterministically generates a sequence of vertices with a maximum length of . To pick one of these numbers and to pick numbers is therefore . the overall algorithm is nondeterministic polynomial time. Each multiplication takes time steps (see time steps and the overall complexity of verification 1. a) To show that a problem is in the algorithm first nondeterministically picks a solution (in polynomial time) and then verifies the solution (in polynomial time). Then it has to be verified that all edges in the cycle (i. an edge between every pair of consecutive vertices in the sequence) exist in the transition table of the graph. This makes the verification algorithm Since the nondeterministic generation of a solution and the verification are both polynomial time on a nondeterministic Turing machine. each of which is no larger than (every number that is the product of more than integers is also the product of exactly integers). The complexity of the first multiplication is . In a last step it compares the results of both calculations. For this problem a solution (or more precisely the string that lets us verify the existence of a solution) is a set of different integers. To multiply 5 integers the algorithm multiplies the first two. and thus requires time steps. Since the nondeterministic generation of a solution and the verification are both polynomial time on a nondeterministic Turing machine. the algorithm multiplies the five numbers and then compares the result to the input.       ¨   ©§    ¨   §    ©§   ¨    s s    ¨   ©§ 9 9 h ¦ w yx9   ¨  ©§ h ¦ ¦ t vu9    ¦    ¨   § ¡ 9 ¦ c 2000 Manfred Huber Page 3 h ¦    ¨§   ¨©§   ¨  § 2    ¨  ©§ g g  r  ©§   ¨ e fd 2. and the overall verification thus complexity can therefore be done in time steps. the algorithm first nondeterministically picks two integers and . so would be ). Then it multiplies and and adds to the result. the overall algorithm is nondeterministic polynomial time. To verify that these are the right numbers the algorithm multiplies and . multiplies the result with the third integer. If they are the same.    ¨ r  ©§  h ' ¦¨ qpi@©§   ¨  § g g     .CSE 3315 . The second multiplication therefore has complexity .a or example in class). All five multiplications have .see 1. requires time To verify that the integers are a correct factorization of the input.

Sign up to vote on this title
UsefulNot useful