# 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 ﬁrst 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 ﬁrst 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 signiﬁcant 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 ﬁrst number string (initially ) is empty. a) If it is empty the multiplication is ﬁnished and the Turing machine halts. 2. Erase the ﬁrst from the ﬁrst 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 ﬁnd out if the graph is connected it is sufﬁcient 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 satisﬁable it is sufﬁcient to show that one of the conjunctive terms to be not satisﬁable it has to contain is satisﬁable. 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 satisﬁable. a) If it does not. The overall complexity is thus . the overall complexity of the algorithm is and thus polynomial. To test satisﬁability 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 ﬁrst 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 satisﬁable. 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 ﬁrst 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 ﬁrst 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.