0% found this document useful (0 votes)
31 views

Assignment 6 Foundation of Algorithms: Chinmay Kulkarni (ck1166)

This document contains the solutions to 6 problems related to algorithms and complexity: 1. Graph isomorphism problem is proved to be NP-complete by describing an algorithm to check isomorphism between two graphs that runs in polynomial time. 2. It is proved that P ≠ NP by showing that if P = NP, then NP = co-NP, which is generally believed to be false. 3. A Boolean circuit is converted to a Boolean expression and shown to be unsatisfiable by checking all possible combinations of input values. 4. Disjunctive normal form is described and it is argued that determining satisfiability of a DNF takes polynomial time. 5. Partition problem is

Uploaded by

Chinmay Kulkarni
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Assignment 6 Foundation of Algorithms: Chinmay Kulkarni (ck1166)

This document contains the solutions to 6 problems related to algorithms and complexity: 1. Graph isomorphism problem is proved to be NP-complete by describing an algorithm to check isomorphism between two graphs that runs in polynomial time. 2. It is proved that P ≠ NP by showing that if P = NP, then NP = co-NP, which is generally believed to be false. 3. A Boolean circuit is converted to a Boolean expression and shown to be unsatisfiable by checking all possible combinations of input values. 4. Disjunctive normal form is described and it is argued that determining satisfiability of a DNF takes polynomial time. 5. Partition problem is

Uploaded by

Chinmay Kulkarni
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

ASSIGNMENT 6

FOUNDATION OF ALGORITHMS
CHINMAY KULKARNI
(ck1166)

1. Given 2 graphs G1 and G2, we need to prove that <GraphIsomorphism> for < G 1,
G2>, which checks whether the 2 graphs are isomorphs of each other is NP problem.
Suppose there is an algorithm which verifies that G 1 and G2 follow isomorphism or
not. It can be done by checking whether the graph G 1 and G2 are permutations of
each other. If yes, then return the following permutation, and if no then graphs G 1
and G2 are not isomorphic.
Once we get the permutation, we apply that permutation to one of the graph and
check whether that graph is identical to other graph.
To get the permutation the algorithm requires O(m 2), where m is number of vertices,
and to check whether the permutation applied to a graph generates an identical
graph to other graph has O(m+n) time complexity.
Overall the algorithms complexity is O(m2), hence it belongs to NP.

2. prove, NP coNP, then PNP


We can follow a contrapositive way to prove this equation,
If P=NP then, NPcoNP,
Suppose X NP, then X

P and since P is closed under complement thats why X

P and

hence
X conP. (1)
For X

coNP, X ' P and since P is closed under complement thats why X P and therefore

NP (2).

From (1) and (2),


We can say that NP=coNP.

3.

When we convert this circuit to Boolean expression we get:

(X3 (X1

X2

X3))

(X3

(X1

X2))

(X1

X2

X3)

And we apply all the combinations of values to X1, X2, X3 we always get a value of 0:
X1

X2

X3

Output

Hence we can say that it is unsatisfiable.

4. A Disjunctive normal form consists of Sum of products i.e. it is in the form of:
(X1

X2

X3)

(X4

X5

X6)

(X7

X8

X9)

Basically in DNF the expression contains sub expressions as product of literals


(which also include complement of literals), and each sub-Expression is summed
with each other.
A DNF can be verified for satisfiability if any of the sub-expressions value is TRUE.
That is if 1 or more than 1 sub-expressions value returned is TRUE, then the overall
expression is satisfiable. To check whether a sub-expression returns TRUE, we need
to check whether a literal and its complement should not exist in sub-expression,
because if thats the case then the sub expression will return value as FALSE.
In order to check whether the overall expression is satisfiable, we need to check
each sub-expression for the above stated check. So if there are P sub-expression,
ad a sub-expression is made up of at most Q literals, then to check whether a subexpression return FALSE requires O(PQ) time complexity.
Hence we can say that determining whether Disjunctive normal form is satisfiable or
not we require polynomial time complexity.

5. We can use subset-sum problem reduction to PARTITION to prove that it is NPcomplete:

Firstly, we can see that PARTITION

NP, because we can guess the subsets in S

so that their sum is equal.


Now we can reduce the subset sum to PARTITION.
Suppose S is the set with subset partitions as A and A, and let p be sum of all the
numbers in S
Subset sum states that given a input of X numbers, from set S and to find whether
the sum of X numbers is target sum t i.e. <X,t> is subset sum if sum of number in X
is equal to t, where X

S.

From our Set S we take A list of numbers, then <A,t> is subset sum and sum of
numbers in A is given as
A = A

(p 2t).

We accept only if Sum of (A i.e. t) and (A i.e. A


in polynomial time.

(p 2t)) is equal and this works

We need to prove this fact,


<A,t>

subset sum and A

PARTITION, where sum of numbers in A = (2p-2t)

If there exists a subset A in S whose sum is t then, hence the remaining numbers in
S will have sum
(p - t), therefore there is partition in A such that both have sum as (p-t).
And now if there is partition in A such that both contain sum p-t, then one of the
partition will contain p-2t, and removing this give us the set of numbers who have
sum as t.
Hence we have reduced Subset sum problem to Partition problem, and as we know
that Subset sum is NP complete, therefore we can say that PARTITION IS NP
complete.

6. a. pseudocode for recursive 0-1 knapsack problem,

def knapsackZeroOneRecursive (targetWt, Values, Weights, n):


targetWTthe target weight to be achived with maximum
corresponding values
Values values associated with n items
Weights weights associated with values in n.
if n=0 or targetWt=0: // base case.
return 0
if weight[n-1]> targetWt: // this means that target weight to
achieve is less than the
// current weight in the weight array. Then we will search for other
weights in array
Return knapsackZeroOneRecursive (targetWt, Values, Weights, n1)

Else:// return the max value between, if nth weight is included or if it is


not included.
Return max(values[n-1]+ knapsackZeroOneRecursive (targetWtWeights[n-1], Values, Weights, n-1) ), knapsackZeroOneRecursive (targetWt, Values,
Weights, n-1))

6.c. The complexity of dynamic programming algorithm for 0-1 knapsack problem is
O(n(targetW)), where n is number of choices of weights and values.
6.d. NO PNP, because we cannot generalize solution of 1 NP complete solution to all the NP
problems.
Because, there are large number of NP Problems of different kinds ,we can reduce all Np Problems to
Np complete problems . The NP complete problems can be verified in polynomial time but cannot be
solved in polynomial time.

You might also like