Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose we have a rod of length n inches and we also have an array of positive integer prices P , where P [ i

Suppose we have a rod of length n inches and we also have an array of positive integer prices P, where P[i] denotes the selling price ($) of a piece that is i inches long. Suppose now we have to pay a cost of $1 per cut. You are only allowed to cut the rod into (positive) integer sized pieces. Define the profit we make as the revenue (sum of prices of the pieces) minus the total cost of cutting. We want an algorithm that finds a way to cut the rod maximizing our profit. For your DP algorithm, use the name MaxProfit for the array which stores values of the subproblems. 1. Subproblems: Define appropriate subproblems MaxProfit in words. You should explain what the entries in MaxProfit are intended to store. 2. Base Cases: State the base case(s) and their value(s). 3. Recurrence: State and justify the recurrence MaxProfit should satisfy. 4. Algorithm: Based on the recurrence, write pseudocode that computes MaxProfit and outputs the maximum profit for the given rod of length n. 5. Run-Time: State and justify the run time of your algorithm as a \Theta expression.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

More Books

Students also viewed these Databases questions