Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

While walking through the Middle East, you come across the Cave of Forty Thieves. In this cave there are n treasures t 1 , t

While walking through the Middle East, you come across the Cave of Forty Thieves. In this cave there are n treasures t1, t2,... tn, which have weights w1, w2,..., wn and values v1, v2,..., vn. Unfortunately, the only sack you carry can carry at most P units of weight before breaking, so you probably won't be able to take all the treasures. Fortunately, you also bring with you a magic knife that allows you to split any treasure that doesn't fit whole in your sack to take just a portion of it. We assume that, when splitting a treasure, it maintains a consistent fraction in terms of its weight and value (that is, the third part of the treasure ti has weight wi/3 and value vi/3). a) Describe a time \theta (n log n) greedy algorithm to maximize the total value of the treasures added to the bag. b) Prove that your algorithm is correct. c) Show how to improve the time to O(n) using the k-selection 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

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 Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

6th International Edition

061921323X, 978-0619213237

More Books

Students also viewed these Databases questions