Question: please give correct answer only and give pseudocode for part ( b ) . There is a large supply of a set of two types

please give correct answer only and give pseudocode for part(b).
There is a large supply of a set of two types of rods R, where each type 1 rod is of length r1 with cost c1 and each type 2 rod is of length r2 with cost c2. You are given a set of n required cut pieces S={x1,x2,dots,xn} where each cut-piece is less than both r1 and r2. You are required to select the required number of rods of each type to accommodate all the pieces of S so that the total cost of rods used is minimum. Given that, if a rod is partly used, the full rod cost has to be paid, develop an optimal algorithm with the following:
(a) Present a suitable recursive definition to find the number of rods of each type. Analyze your recursive definition in terms of identical sub-problems produced, if any.
(b) Present both top-down and iterative Dynamic Programming based algorithms for the recursive definition. Analyze the time and space complexity of your algorithms.
(c) Show the working of the iterative algorithm on a non-trivial example of at least 15 elements clearly indicating all storage elements memorized and used.
please give correct answer only and give

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!