Question: 6) Consider the following greedy algorithm for the rod-cutting problem i. given a remaining length of k inches, determine the value per inch for each
6) Consider the following greedy algorithm for the rod-cutting problem i. given a remaining length of k inches, determine the value per inch for each length I from 1 to k i. cut at length I which maximizes the value per inch (use the largest value of I to break ties); this produces a piece A of length I and a piece B of length k-I ili. repeat steps i and i with piece B until no more cuts are made (best i k) This greedy algorithm is not guaranteed to solve the problem optimally Give an example input that the greedy algorithm would solve sub-optimally. State both the greedy solution and the optimal solution. (7 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
