Question: In java Implement two versions of the pseudo algorithm of the Rod Cutting Problem in Java use a table below for a sample price with

In java

In java Implement two versions of the pseudo algorithm of the Rod

Implement two versions of the pseudo algorithm of the Rod Cutting Problem in Java use a table below for a sample price with pi dollars of revenue for the length i length i 1 2 3 4 5 6 7 8 9 10 price Pi 1 5 8 9 10 17 17 20 24 30 Figure 15.1 A sample price table for rods. Each rod of length i inches carns the company Pi dollars of revenue. A. user will enter a number for n, the size of the rod. b. For each of the two algorithms, determine the optimal revenue rn with the corresponding optimal decompositions of the n and display the revenue and decompositions. c. For each of the two algorithms, count a total number of recursive calls made in determining rn and display/compare them. d. Repeat a-c at least 5 times and show the results. Recursive top-down implementation CUT-ROD(p.n) 1 if n == 0 2 return 0 3 q = - 4 for i = 1 ton 5 q = max(q, pli] + CUT-ROD(p,n i)) 6 return Recursive top-down implementation with memoization MEMOIZED-CUT-ROD (p, n) 1 let r[O..n] be a new array 2 for i = 0 ton 3 r[i] = - 4 return MEMOIZED-CUT-ROD-AUX(p,n,r) auw MEMOIZED-CUT-ROD-AUX(p,n,r) 1 if r[n] > 0 2 return r[n] 3 if n == 0 q=0 else q = -00 6 for i = 1 ton q = max(q, p[i] + MEMOIZED-CUT-ROD-AUX(p.n-i,r)) r[n] = 9 9 return

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 Databases Questions!