# Input s t where s f x1 x2 xkg variables integers

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: c imal enc oding, unary enc oding will grow the input s iz e ex ponentially . Therefore, the reduc tion to generate the c orres ponding input for UNARY­SSUM will require a number of s teps that is ex ponential in the s iz e of the input, tak ing more than poly nomial time. The proof fails . 2.) SU BSET À SU M is in P bec aus e the following poly nomial time algorithm bas ed on dy namic programming s olv e the problem. Input: (S; t) , where S = f x1 ; x2 ; :::; xkg Variables : Integers i; j; l[0 ::k][0 ::t] , all are initializ ed to 0 l[0 ][0 ]← 1 ; f or i = 1 to k do f or j = 0 to t À xi do if l[i À 1 ][j] = 1 then l[i][j + xi] ← 1 ; od od if l[k][t] = 1 then accep t else reject; 7.17 As s ume that P = N P : Let B 2 P but B = ¶ and B = ÆÃ s uc h that there ex is t a s tring = = waccep t 2 B and a s tring wrej ect 2 B . To s how B in P = N P is NP­c omplete, let A be an = arbitrary language in P = N P . Therefore, A c an be dec ided by a poly nomial time dec ider M A . Nex t, we s how a poly nomial time reduc tion M from A to B as follows . M = ”On input w : 1. Run M A on w . 2. If M A ac c epts then output waccep t . If M A rejec ted then output wrej ect .” Obv ious ly , there ex is ts a poly nomial time reduc tion from A to B . Henc e B is NP­c omplete. 7.20 a.) SP AT H is in P bec aus e the following TM M c an dec ide it in poly nomial time. M = “On input ⟨G; a; b; k⟩ where G is a graph with n nodes , two whic h are a and b: 1. Mark node a 0 2. For eac h i from 0 to n : a. If an edge (s; t) is found c onnec ting s mark ed i to an unmark ed node i , mark node t with i + 1 . 3. If b is mark ed with a v alue of at mos t b , ac c ept. Otherwis e, rejec t.” b.) LP AT H 2 N P bec aus e a path from a to b c an be gues s ed by an NTM nondeterminis tic ally and c hec k ed if its length is at leas t k in poly nomial time. Nex t, we s how U H AM P AT H Ôp LP AT H by c ons truc ting a TM F that c omputes the reduc tion f . F = “On input ⟨G; a; b⟩ of U H AM P AT H , where G is a graph with two nodes a and b: 1. Let k be the number of nodes of G. 2. Output ⟨G; a; b; k⟩ as an ins...
View Full Document

Ask a homework question - tutors are online