Design a dynamic programming algorithm for the following problem. Find the maximum total sale price that...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Design a dynamic programming algorithm for the following problem. Find the maximum total sale price that can be obtained by cutting a rod of n units long into integer-length pieces if the sale price of a piece i units long is pi for i = 1, 2,..., n. Optional: what are the time and space efficiencies of your algorithm? 8) Minimum-sum descent: Some positive integers are arranged in an equilateral triangle with n numbers in its base like the one shown in the figure below for n = 4. The solution for this example is highlighted: 2 5 4 1 47 8 696 The problem is to find the smallest sum in a descent from the triangle apex to its base through a sequence of adjacent numbers (shown in the figure by dashes). Design a dynamic programming algorithm for this problem. Optional: indicate its time efficiency. Hint: you might want to represent the data in a table like this: 0 12 3 0 2 5 1 8 1 2 4 4 6 7 9 3 6 (not from the book) N-Choose-K problem: Design a dynamic programming algorithm for the recursive n-choose-k problem discussed in class (and outlined below). Optional: indicate its time and space complexity. Hint: Pascals Triangle reveals n choose k. From the peak (the value of 1) move down the triangle by n, and then to the right by k to find the solution for n choose k in the triangle. Pascals Triangle up to n = 6: 1 11 121 1331 14641 1 5 10 10 51 1 6 15 20 15 6 1 The n choose k problem: I have five friends I want to invite to my birthday party. Mom says I can only invite three. How many ways can I invite these three friends? This is a 5 choose 3 problem. Here is the classic n choose k formula: n! k! (n - k)! From this formula we can figure out there are 10 ways to invite 3 people out of 5 friends. But how could we do this recursively? Let's imagine Albert is my best friend in the whole world (and one of my five possible friends to invite). Let's call Albert 'a'. From 5 choose 3, if Albert is invited we are left with a 4 choose 2 problem. From 5 choose 3, if Albert is not invited, we are left with a 4 choose 3 problem. Here are all the ways I can invite 3 of 5 friends: abc, abd, abe, acd, ace, ade, these are all the ways we can 5 choose 3 if Albert is invited bcd, bce, bce, bde, and cde - these are all the ways we can 5 choose 3 if Albert is not invited So the total number of ways we can invite 3 out of 5 friends can be found by having children to do work for the smaller n choose k problems. And the recursive formula for f(n,k) is: f(n,k) = (n-1, k-1) + (n-1, k) If we apply dynamic programming we can improve this recursive solution...that is your task. Design a dynamic programming algorithm for the following problem. Find the maximum total sale price that can be obtained by cutting a rod of n units long into integer-length pieces if the sale price of a piece i units long is pi for i = 1, 2,..., n. Optional: what are the time and space efficiencies of your algorithm? 8) Minimum-sum descent: Some positive integers are arranged in an equilateral triangle with n numbers in its base like the one shown in the figure below for n = 4. The solution for this example is highlighted: 2 5 4 1 47 8 696 The problem is to find the smallest sum in a descent from the triangle apex to its base through a sequence of adjacent numbers (shown in the figure by dashes). Design a dynamic programming algorithm for this problem. Optional: indicate its time efficiency. Hint: you might want to represent the data in a table like this: 0 12 3 0 2 5 1 8 1 2 4 4 6 7 9 3 6 (not from the book) N-Choose-K problem: Design a dynamic programming algorithm for the recursive n-choose-k problem discussed in class (and outlined below). Optional: indicate its time and space complexity. Hint: Pascals Triangle reveals n choose k. From the peak (the value of 1) move down the triangle by n, and then to the right by k to find the solution for n choose k in the triangle. Pascals Triangle up to n = 6: 1 11 121 1331 14641 1 5 10 10 51 1 6 15 20 15 6 1 The n choose k problem: I have five friends I want to invite to my birthday party. Mom says I can only invite three. How many ways can I invite these three friends? This is a 5 choose 3 problem. Here is the classic n choose k formula: n! k! (n - k)! From this formula we can figure out there are 10 ways to invite 3 people out of 5 friends. But how could we do this recursively? Let's imagine Albert is my best friend in the whole world (and one of my five possible friends to invite). Let's call Albert 'a'. From 5 choose 3, if Albert is invited we are left with a 4 choose 2 problem. From 5 choose 3, if Albert is not invited, we are left with a 4 choose 3 problem. Here are all the ways I can invite 3 of 5 friends: abc, abd, abe, acd, ace, ade, these are all the ways we can 5 choose 3 if Albert is invited bcd, bce, bce, bde, and cde - these are all the ways we can 5 choose 3 if Albert is not invited So the total number of ways we can invite 3 out of 5 friends can be found by having children to do work for the smaller n choose k problems. And the recursive formula for f(n,k) is: f(n,k) = (n-1, k-1) + (n-1, k) If we apply dynamic programming we can improve this recursive solution...that is your task.
Expert Answer:
Answer rating: 100% (QA)
Answer Dynamic Programming Algorithm Create an array maxPrice of size n1 to store the maximum total ... View the full answer
Related Book For
Managerial Economics
ISBN: 978-0133020267
7th edition
Authors: Paul Keat, Philip K Young, Steve Erfle
Posted Date:
Students also viewed these programming questions
-
Mifflin Company reported the following for the current year: Net sales Cost of goods sold Beginning balance in accounts receivable Ending balance in accounts receivable $ 66,780 42,000 14,800 6,400...
-
Calculate and plot the equilibrium line at T = 15 where the henry constant at given temperature is 8.86 atm. The operating pressure of the column is 25 bar. The flowrate of total gas inlet is 1500...
-
A company applies overhead at a rate of 190% of direct labor cost. Actual overhead cost for the current period is $1,255,500, and direct labor cost is $651,000. 1. Compute the under- or overapplied...
-
Last year, Lena biked 330 miles. This year, she biked k miles. Using k, write an expression for the total number of miles she biked.
-
A uniform horizontal disc fixed at its centre to an elastic vertical rod performs forced torsional oscillations due to the moment of forces Nz = Nm cos cot. The oscillations obey the law = m cos (wt ...
-
On January 1 , 2 0 1 3 , Lindsay Owens opened Picture Perfect, a small retail store that sells picture frames, crafts & art. On June 3 0 , 2 0 1 4 , her accounting records show the following: Store...
-
Responsibilities of an object define what they know and what they do. Provide an example for each.
-
The medical community unanimously agrees on the health benefits of regular exercise, but are adults listening? During each of the past 15 years, a polling organization has surveyed Americans about...
-
Under Working Capital Management and Debt What are some of the advantages and disadvantages of short-term vs long-term debt? What are some actions a firm can take to shorten its cash? Public and...
-
The following data relate to the operations of Shilow Company, a wholesale distributor of consumer goods: Current assets as of March 31: Cash $ 8,000 Accounts receivable 20,000 Inventory 36,000...
-
Evaluate the following integral: Sex dx
-
Explain the difference between regulative rules and constitutive rules.
-
_____________ requires you to research opportunities in your major that correspond with your goals and priorities.
-
What is the difference between hearing and listening, and why does it matter?
-
Identify the six stages of the job interview process.
-
It is _____________ for an interviewer to ask an interviewee questions relating to race, color, religion, sex, national origin, disability, or age.
-
The frictional resistance for fluids in motion is a. Proportional to the velocity in both laminar and turbulent flow O b. OC O d. Proportional to the velocity in laminar flow and to the square of the...
-
Suppose Green Network Energy needs to raise money to finance its new manufacturing facility, but their CFO does not think the company is financially capable of making the periodic interest payments...
-
As capital investment analyst for the Parkhurst Printing Corporation, you have been asked to evaluate the advisability of purchasing a new printing press to accommodate projected increases in demand....
-
Why do companies use the RADR method much more frequently than the certainty equivalent method?
-
You own a large collection of fine wines. You now decide that you must liquidate this valuable asset. However, you predict that the value of your collection will rise in the next few years. The...
-
Near the state capitol, a heritage center houses historical artifacts of significance to the state dating from pre-statehood to the present. The center is particularly well done and serves as both a...
-
Opponents to charging an entrance fee as described in Problem 32 note that only 15,000 visitors will utilize the heritage center, and the benefits of \(\$ 5(14,000)+\$ 3(12,000)=\$ 106,000\) derived...
-
The federal government is planning a hydroelectric project for a river basin. The project will provide electrical energy to the local area and to the grid. With some enhancements to the basic plan,...
Study smarter with the SolutionInn App