Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

algorithm 4. Consider the problem of weighing an integer amount n using the fewest number of weight pieces. We have 4 types of weight pieces;

algorithm
image text in transcribed
4. Consider the problem of weighing an integer amount n using the fewest number of weight pieces. We have 4 types of weight pieces; 1kg,5kg,10kg, and 25kg. Assume any weight piece is infinitely available. A greedy algorithm iteratively selects the largest weight piece that does not take us past the amount to be weighed, decreases the amount to be weighed by the weight of the selected piece, and continues iteratively. For instance to weigh 123 kilograms, the greedy algorithm selects the weight pieces in the following order: 25+25+25+25+10+ 10+1+1+1, making use of a total of 9 weight pieces. Prove or disprove whether the greedy algorithm provides the optimum solution for any value of n. 5. Repeat Question 4, this time assuming that the available types of weights are w0,w1,,wk for some integers w>1,k1. 6. [10pts] Consider the same problem defined in Question 4. This time give a set of types of weights for which the greedy algorithm does not yield an optimal solution. Note that your set should include 1kg weights so that there is a solution for every value of n

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

Entity Alignment Concepts Recent Advances And Novel Approaches

Authors: Xiang Zhao ,Weixin Zeng ,Jiuyang Tang

1st Edition

9819942527, 978-9819942527

More Books

Students also viewed these Databases questions

Question

Networking is a two-way street. Discuss this statement.

Answered: 1 week ago