Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2 Caveat Venditor Due to dwindling popularity, the world's last DVD store is closing down and having a sale to get rid of their remaining

2 Caveat Venditor
Due to dwindling popularity, the world's last DVD store is closing down and having a sale to get
rid of their remaining inventory of movies. Every movie costs the same amount C crowns, and in
addition they have distributed a large number of coupons all over town with offers along the lines
of "Buy any five movies, get two of them for free". This means that you can get any 5 movies in
the store (even 5 copies of the same movie) for a cost of 3*C crowns (instead of 5*C crowns).
An avid DVD collector wants to buy n 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 the discount coupons (for
some reason, nobody else was interested in them). The coupons can have different offerings. E.g.,
one could be "buy three, get one for free", another could be "buy 100, get 5 for free", etc. Now
the collector has a conundrum: what is the best way to use these coupons in order to get all n
movies as cheaply as possible? It is fine to buy a few additional movies if that leads to a smaller
total cost (see example below). Each coupon can only be used once.
Design an algorithm which given the set of available coupons, finds the smallest total cost of
buying the n movies. The algorithm must have time complexity polynomial in n and m, assuming
a unit cost analysis (e.g., you may assume that adding/multiplying/comparing two numbers
takes O(1) time). The input to the algorithm consists of:
The integers n,m, and C as described above.
For each 1im, a pair of integers (bi,fi)(where 1fibin), indicating that the
i'th coupon says "buy bi, get fi for free".
image text in transcribed

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

Step: 3

blur-text-image

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

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions

Question

Discuss the impact of analytics on workplace ergonomics

Answered: 1 week ago

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago