Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

''' SUM-OF-SUBSETS Problem Instance: A finite set A = {a1,a2,....,am} and M Question: Is there A in A s.t. ai in A'ai= M? Given that

'''

SUM-OF-SUBSETS Problem

Instance: A finite set A = {a1,a2,....,am} and M

Question: Is there A in A s.t. ai in A'ai= M?

Given that the TWO2ONE-Partition problem is NP-complete, prove that the SUM-OF-SUBSETS

the problem is NP-complete by reducing the TWO2ONE-partition problem to it.

  1. Give a nondeterministic polynomial time algorithm for the SUM-OF-SUBSETS problem.

(Use Guess statements in your solution, e.g Guess({0,1}) returns 0 or 1)

'''

Algorithm

:

  1. Non-deterministic algorithm for SUM-OF-SUBSETS

For every element randomly Guess if it is part of subset

Guess(ai in subset)

1 if Yes (O(m))

0 if No (O(m))

check if sum of selected elements which have Guess( ) == 1, is M

if Yes, return True and this is the solution

if No, repeat above

Write the working code in Python for above algorithm?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions

Question

=+ Are there additional forms of employee representation?

Answered: 1 week ago

Question

=+What is the nature of their impact?

Answered: 1 week ago