Question: Caveat Emptor ( NP - completeness, easier ) Due to dwindling popularity, the world s last DVD store is closing down and having a sale
Caveat Emptor NPcompleteness, easier
Due to dwindling popularity, the worlds last DVD store is closing down and having a sale to get
rid of their remaining inventory of movies.
An avid DVD collector wants to buy a certain set S of the movies available in the store, and
to get the best deal they have gone around town and collected a large number m of discount
coupons for some reason, nobody else was interested in them Each coupon has a discount for
a specific movie package. For instance one coupon could say Get all Star Wars movies for
the price of a single movie! More generally, each coupon is of the form Get all movies in the
set T for the price of a single movie!
The collector has a budget that would allow them to pay for a total of b single movies. In other
words they can choose a total of up to b different coupons andor individual movies to buy. It is
fine to buy a few additional movies if that leads to smaller total cost, or even to buy the same
movie more than once. Eg if S only contains the first three Star Wars movies then it could
still make sense to use the example coupon above to buy all Star Wars movies.
Prove that it is NPcomplete to decide whether or not the collector can succeed in buying the
movies in S or not, for a total of at most b In other words, the input in this problem consists
of the set S of movies to buy, the budget b the number m of coupons, together with a list of
m sets T T Tm describing the coupons, where Ti
is the set of movies included in the ith
available coupon.
You may use a reduction involving any of the following known NPhard problems which were
discussed in lectures, exercises and the book, listed here in alphabetical order: Coloring,
Dimensional Matching, Sat, CNFSat Graph Coloring, Hamiltonian Cycle,
Hamiltonian Path, Independent Set, Knapsack, Load Balancing, Set Cover, Subset
Sum, Travelling Salesman, Vertex Cover.
I started solve the problem and here is my solution but Im not sure if my solution is correct and I don't know how to write a psudocode fo the problem.
here is my soltuion:
Input format:
S the set of movies to buy.
b the budget
m the number of coupons together with a list of m sets T T Tm describing the coupons, where Ti is the set of movies included in the ith available coupons.
Solution for the problem:
To prove that the given problem is NPcomplete, we need to show two things:
The problem is in NP which means that the solution can be verified in polynomial time.
The problem is NPhard which means it is at least as hard as any other problem in NP
The problem we are dealing with can be framed as a variant of the Subset Sum problem, which is known to be NPcomplete.
Step : let us show that the problem is in NP
To prove that the problem is in NP class, we need to show that given a solution in our case a subset of movies that can be bought within the budget we can efficiently verify whether this solution is correct.
Given a subset T of movies from S that includes individual movies and movies obtained though coupons, we can:
Compute the total cost CT of purchasing this subset of movies. This involves considering the individual movie and applying any applicable coupons to get the effective cost.
Check if CT b If this condition is satisfied, then T is a valid solution within the budget b
Calculate Total Cost CT:
For each movie in T:
If m is an individual movie and its not covered by any coupon, then we can add its cost costm directly to the total cost CT
If m is part of a coupon Ti ie all movies in Ti can be purchased for the price of one movie so verify that the coupon can be applied:
Check if all movies in Ti are present in T If yes, increment the count of coupon applications for Ti in T which is denoted as count Ti T
Now we can compute the effective total cost by summing up the costs of individual movies and adjusting for the coupons that have been applied:
CTm T'cost m Ti applied in T'count TiT x sizeTi
costm represent the cost of purchasing movie m
Ti is a coupon where size Ti is the number of movies in the coupon excluding the price of one movie
countTi T is the number of times coupon Ti is applied in T
Verification of budget constraint:
After computing CT we check if CT b where b is the budget.
If CT b then T is a valid solution within the budget b
Step : NPHardness Reduction from Subset Sum
To prove NPhardness, we will reduce the wellknow NPcomplete problem Subset Sum to our problem.
Subset Sum problem:
Given a set of integers x x xn and a target sum B can we find a subset
Sx x xn such that the sum of elements in S is equals B
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
