Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

2. Youre walking along the beach and you stub your toe on something in the sand. You dig around it and find that it is

2. Youre walking along the beach and you stub your toe on something in the sand. You dig around it and find that it is a treasure chest of k gold bricks of different (integral) weight. Your knapsack can only carry up to weight n before it breaks apart. You want to put as much in it as possible without going over, but you cannot break the gold bricks up.

(a) Suppose that the k gold bricks have the weights 1, 2, 4, 8, . . . , 2 k1 , for k 1. Describe a greedy algorithm that fills the knapsack as much as possible without going over.

(b) Prove that your algorithm is correct.

(c) Give an example, including a multiset of different weight values of bricks and total weight n that the knapsack can carry up, for which the greedy algorithm does not yield an optimal solution

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

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students explore these related Databases questions