Question

Prove that your algorithm works! 6.) Dynamic Consider a modification of the rod-cutting problem in which, in addition to a price p, for each rod, each cut incurs a fixed cost of c. The revenue associated with a solution is now the sum of the prices of the pieces minus the costs of making the cuts. Give a dynamic-programming algorithm to solve this modified problem. Prove that your algorithm works.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

EXTEDED-BOTTOM-UP-CUT-ROD (p,n, c) pisa array having price for each length o is size of rod. is fixed cost 1. Let rlO.n] and s[O..n] be new arraysr[O..n] is for storing revenue Sto.n] is for storing cut sizes 2. r[o] O 3. for j 1 to n//for checking every possible length a, q=p[j] it is modification in rod cut solution.Without cut if we have high profit then no need of cutting and no need of reducing fixed cut cost b. fori-1 to j-1 here while comparing before cutting and after cutting we reduce the cut cost c.So actual profit after cutting will became 4. return r and s

Proof: by tracing the above algorithm for some input data we can understand the working .

Length i

1

2

3

4

5

6

7

8

Price pi

1

5

8

9

10

17

17

20

n = 9 , c = 2

if p,n,c are we passed to our algorithm.

r[0..n], s[0..n] two arrays

r[0] = 0

for j=1

                q= p[j]

                inner loop i = 1 to j-1

                                here j-1 is 0 so loop break;

for j=2

                q= p[j]

                inner loop i = 1 to j-1

                                q < p[i] + p[j-i] – c   means 5 < 1 + 1 – 2 is false so we don’t cut here

                still now we store r[0]=0,r[1]=1,r[2]=5 there are optimal only.

for j=3

                q= p[j] = 8

                inner loop i = 1 to j-1

                                q < p[i] + p[j-i] – c   means 8 < 1 + 5 – 2 is false so we don’t cut here

                                q <p[2] + p[1] – c means 8 < 5 + 1 -2 is false so we don’t cut here

                still now we store r[0]=0,r[1]=1,r[2]=5 r[3]=8 there are optimal only.

for j=4

                q= p[j] = 9

                inner loop i = 1 to j-1

                                q < p[i] + p[j-i] – c   means 9 < 1 + 8 – 2 is false so we don’t cut here

                                q <p[2] + p[2] – c means 9 < 5 + 5 -2 is false so we don’t cut here

                                q <p[3] + p[1] – c means 9 < 8 + 1 -2 is false so we don’t cut here

                still now we store r[0]=0,r[1]=1,r[2]=5 r[3]=8 r[4]=9

for j=5

                q= p[j] = 10

                inner loop i = 1 to j-1

                                q < p[i] + p[j-i] – c   means 10 < 1 + 9 – 2 is false so we don’t cut here

                                q <p[2] + p[3] – c means 10 < 5 + 8 -2 is true so we cut here.

                                q = 5 + 8 -2 = 11

s[j] = i // adding the split where we did cutting.

                                q <p[3] + p[2] – c means 11 < 8 + 5 -2 is false so we don’t cut here

                                q <p[4] + p[1] – c means 11 < 9 + 1 -2 is false so we don’t cut here

r[5] =11

                still now we store r[0]=0,r[1]=1,r[2]=5 r[3]=8 r[4]=9 r[5] =11

for j=6

                q= p[j] = 17

                inner loop i = 1 to j-1

                                q < p[i] + p[j-i] – c   means 17 < 1 + 11 – 2 is false so we don’t cut here

                                q <p[2] + p[4] – c means 17 < 5 + 9 -2 is false.

                                q <p[3] + p[3] – c means 17 < 8 + 8 -2 is false so we don’t cut here

                                q <p[4] + p[2] – c means 17 < 9 + 5 -2 is false so we don’t cut here

                                q <p[5] + p[1] – c means 17 < 11+ 1 -2 is false so we don’t cut here

r[6] =17

                still now we store r[0]=0,r[1]=1,r[2]=5 r[3]=8 r[4]=9 r[5] =11 r[6] =17

for j=7

                q= p[j] = 17

                inner loop i = 1 to j-1

                                q < p[i] + p[j-i] – c   means 17 < 1 + 17 – 2 is false so we don’t cut here

                                q <p[2] + p[5] – c means 17 < 5 + 11 -2 is false.

                                q <p[3] + p[4] – c means 17 < 8 + 9 -2 is false so we don’t cut here

                                q <p[4] + p[3] – c means 17 < 9 + 8 -2 is false so we don’t cut here

                                q <p[5] + p[2] – c means 17 < 11+ 5 -2 is false so we don’t cut here

                                q <p[6] + p[1] – c means 17 < 17+ 1 -2 is false so we don’t cut here

r[7] =17

                still now we store r[0]=0,r[1]=1,r[2]=5 r[3]=8 r[4]=9 r[5] =11 r[6] =17 r[7]=17

for j=8

                q= p[j] = 20

                inner loop i = 1 to j-1

                                q < p[i] + p[j-i] – c   means 20 < 1 + 17 – 2 is false so we don’t cut here

                                q <p[2] + p[6] – c means 20 < 5 + 17 -2 is false.

                                q <p[3] + p[5] – c means 20 < 8 + 11 -2 is false so we don’t cut here

                                q <p[4] + p[4] – c means 20 < 9 + 9 -2 is false so we don’t cut here

                                q <p[5] + p[3] – c means 20 < 11+ 8 -2 is false so we don’t cut here

                                q <p[6] + p[2] – c means 20 < 17+ 5 -2 is false so we don’t cut here

                                q <p[7] + p[1] – c means 20 < 17+ 1 -2 is false so we don’t cut here

r[8] =20

                still now we store r[0]=0,r[1]=1,r[2]=5 r[3]=8 r[4]=9 r[5] =11 r[6] =17 r[7]=17 r[8] =20

returns r and s now.

In our problem we get profit without cuts only because the cutting cost is more .

if we trace the algorithm with different cut costs we can understand in better way.

Add a comment
Know the answer?
Add Answer to:
Prove that your algorithm works! 6.) Dynamic Consider a modification of the rod-cutting problem in which,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Rod-cutting problem Design a dynamic programming algorithm for the following problem. Find the maximum total sale...

    Rod-cutting problem 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. What are the time and space efficiencies of your algorithm? Code or pseudocode is not needed. Just need theoretical explanation with dynamic programming with recurrence relation...

  • Psuedocode works! DP is dynamic programming for this algorithm Problem 4.2. (Difficulty 3) Seam carving is...

    Psuedocode works! DP is dynamic programming for this algorithm Problem 4.2. (Difficulty 3) Seam carving is a real-world application of DP for content- aware image resizing. The simplest way to reduce the size of an image is cropping and scaling, i.e. cutting out parts of the image and scaling down the size. However, cropping leaves visible crop lines of incontinuity while scaling reduces the details of the image. We would like to intelligently reducing the size while accounting for the...

  • Two-Part Pricing Problem You can get a maximum of two-percentage points added to your test average...

    Two-Part Pricing Problem You can get a maximum of two-percentage points added to your test average without using calculus. Use your knowledge about price-searching firms and two-part pricing to advise the company below. The company has a bar and is trying to decide on the cover charge (if any) and price for each drink. It has done a modest survey to ask customers to classify themselves as light drinkers or heavy drinkers and to indicate the number of drinks they...

  • This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation...

    This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...

  • i will give a thumb up for sure if it helps me :) Please Summarize this...

    i will give a thumb up for sure if it helps me :) Please Summarize this article about Communicating competitive information,and Applying Game Theory To Managing Price Competition. Pricing Strategies Course -No longer than 400 words. Like any other type of market research, information about competitors will be most valuable if it is collected and stored in a systematic way. Activities such as shopping the competition should be done thoroughly and periodically. Information from different sources should be merged into...

  • Please use own words. Thank you. CASE QUESTIONS AND DISCUSSION > Analyze and discuss the questions...

    Please use own words. Thank you. CASE QUESTIONS AND DISCUSSION > Analyze and discuss the questions listed below in specific detail. A minimum of 4 pages is required; ensure that you answer all questions completely Case Questions Who are the main players (name and position)? What business (es) and industry or industries is the company in? What are the issues and problems facing the company? (Sort them by importance and urgency.) What are the characteristics of the environment in which...

  • Budgeting for an Academic Department at a State University: Can You Believe the Numbers? INTRODUCTION You...

    Budgeting for an Academic Department at a State University: Can You Believe the Numbers? INTRODUCTION You are the senior accounting faculty member in the business school and your dean, Dean Weller, is asking for help. She is very discouraged after a midyear budget meeting with the Vice President of Finance. The college's Department of Social Work has a large budget deficit, and because of this the VP is inclined towards closing the department entirely or closing its bachelor's program. The...

  • I need Summary of this Paper i dont need long summary i need What methodology they used , what is the purpose of this p...

    I need Summary of this Paper i dont need long summary i need What methodology they used , what is the purpose of this paper and some conclusions and contributes of this paper. I need this for my Finishing Project so i need this ASAP please ( IN 1-2-3 HOURS PLEASE !!!) Budgetary Policy and Economic Growth Errol D'Souza The share of capital expenditures in government expenditures has been slipping and the tax reforms have not yet improved the income...

  • CASE 20 Enron: Not Accounting for the Future* INTRODUCTION Once upon a time, there was a...

    CASE 20 Enron: Not Accounting for the Future* INTRODUCTION Once upon a time, there was a gleaming office tower in Houston, Texas. In front of that gleaming tower was a giant "E" slowly revolving, flashing in the hot Texas sun. But in 2001, the Enron Corporation, which once ranked among the top Fortune 500 companies, would collapse under a mountain of debt that had been concealed through a complex scheme of off-balance-sheet partnerships. Forced to declare bankruptcy, the energy firm...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT