a) Write a program that prompts the user to input the prices for rod lengths from...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
a) Write a program that prompts the user to input the prices for rod lengths from 1 to 10. b) Prompt the user for an input rod length (it must be between 1 and 10). Let's call this variable n. c) Output the maximum revenue for a rod of length n (i.e. r). d) Output the cuts the yield the maximum revenue. Example: inputs: prices: [1, 5, 8, 9, 10, 17, 17, 20, 24, 30] n: 7 output: maximum revenue 18. rod cuts 1, 6 Important: a) You must use bottom-up dynamic programming (i.e. no recursion). b) In class, we wrote code to compute the "r" and "s" arrays, but we did not write code to use the "s" array to cut the rod. I'd like to see how you write this code (Hint: It's very simple). a) Write a program that prompts the user to input the prices for rod lengths from 1 to 10. b) Prompt the user for an input rod length (it must be between 1 and 10). Let's call this variable n. c) Output the maximum revenue for a rod of length n (i.e. r). d) Output the cuts the yield the maximum revenue. Example: inputs: prices: [1, 5, 8, 9, 10, 17, 17, 20, 24, 30] n: 7 output: maximum revenue 18. rod cuts 1, 6 Important: a) You must use bottom-up dynamic programming (i.e. no recursion). b) In class, we wrote code to compute the "r" and "s" arrays, but we did not write code to use the "s" array to cut the rod. I'd like to see how you write this code (Hint: It's very simple).
Expert Answer:
Answer rating: 100% (QA)
Solution Sure here is a Python program that solves the rod cutting problem using bottomup dynamic programming def rodcuttingprices n Solves the rod cu... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these algorithms questions
-
Given the extended timeline for development finance cases, explain how real estate finance law and the legal documentation operate to protect the interests of the paramount mortgagee granting loan...
-
Write a computer program that prompts the user to input their gender, weight, height, and age, and in turn estimates their basal metabolic rate. The basal metabolic rate (BMR) approximates the number...
-
Choose a topic that can be applied to one of the following economic concepts. (Possible curves: Lorenz curve, marginal product of labor curve, labor demand and supply curves, utility function and...
-
3) Sauseda Corporation has two operating divisions-an Inland Division and a Coast Division. The company's Customer Service Department provides services to both divisions. The variable costs of the...
-
Find the limit, if it exists. If the limit does not exist, explain why. |x + 4|| 39. lim |x + 4| 40. lim *--4- X + 4 --4 |x- 2| 2r2 - 3x 41. lim x-2 - 2 42. lim x-15 2x - 3 44. lim (-) 43. lim |x|
-
Assume that you have the following function definition. def sign(x): if x > 0: return 'Positive' elif x < 0: return 'Negative' What would be returned when sign (0) is called?
-
Consider all 40 observations on the delivery time data. Delete \(10 \%\) (4) of the observations at random. Fit a model to the remaining 36 observations, predict the four deleted values, and...
-
Sentry, Inc. was started on January 1, Year 1. Year 1 Transactions 1. Acquired $20,000 cash by issuing common stock. 2. Earned $62,000 of revenue on account. 3. On October 1, Year 1, borrowed $12,000...
-
(g) Explain why it is necessary to exit from an investment and list the pros and cons to both a venture capitalist investor and the company's management team of exiting via a trade sale and via a...
-
Wayland Custom Woodworking is a firm that manufactures custom cabinets and woodwork for business and residential customers. Students will have the opportunity to establish payroll records and to...
-
List 2 aspects which must be considered for the each of the stages listed below with reference to stocks, sauces and soups to ensure safe temperatures and hygiene procedures. Production S torage...
-
What characteristics must a project have in order for critical path scheduling to be applicable?
-
Describe the unique characteristics of OOSAD projects that have ramifications for how these projects are managed.
-
Why is planning too much up front a mistake in an OOSAD project?
-
Why should project managers complete hard problems first in an OOSAD project?
-
The text deemphasizes the fact that people are social creatures who feel a need to conform to norms; Post- Keynesians emphasize norms. a. Who shapes these social norms? b. Does society as a whole...
-
Q4. W a. Let be the subset of b=2a +1. W 2 R 6 b consisting of all vectors of the form Le R or not? Examine is a subspace of 2 1 b. If possible, find a diagonal matrix similar to the following...
-
Synthesize the products by drawing out reagents and intermediates along the way. `N H. OH HO HO
-
Diane is a single taxpayer who qualifies for the earned income credit. Diane has two qualifying children who are 3 and 5 years old. During 2012, Diane's wages are $17,100 and she receives dividend...
-
Dr. Ivan I. Incisor and his wife Irene are married and file a joint return for 2012. Ivan's Social Security number is 477-34-4321 and he is 48 years old. Irene I. Incisor's Social Security number is...
-
John Williams (age 42) is a single taxpayer, and he lives at 1324 Forest Dr., Reno, NV 89501. His Social Security number is 555-94-9358. John's earnings and withholdings as the manager of a local...
-
Two radio stations have the same power output from their antennas. One broadcasts AM at a frequency of \(1000 \mathrm{kHz}\) and one broadcasts FM at a frequency of \(100 \mathrm{MHz}\). Which...
-
A paramecium is covered with motile hairs called cilia that propel it at a speed of \(1 \mathrm{~mm} / \mathrm{s}\). If the paramecium has a volume of \(2 \times 10^{-13} \mathrm{~m}^{3}\) and a...
-
Photon P in Figure Q28.35 moves an electron from energy level \(n=1\) to energy level \(n=3\). The electron jumps down to \(n=2\), emitting photon \(\mathrm{Q}\), and then jumps down to \(n=1\),...
Study smarter with the SolutionInn App