Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a functional C++ program to display the following output: Given a rod of length n inches and a table of prices p i for

Write a functional C++ program to display the following output:

Given a rod of length n inches and a table of prices pi for i = 1, 2, ...,n, determine the maximum revenue rn obtainable by cutting up the rod and selling the pieces. Note that if the price pn for a rod of length n is large enough, an optimal solution may require no cutting at all.

Your program must output the running time for rod-lengths of 1 to 30.

Include the running-time behavior, expressed as Big-O.

Requirements:

1.) C++ code that displays the optimal revenue for lengths (n) 1 to 30

2.) For each length, the code must display the run-time for the algorithm (note: I am not interested in run-time for the entire program, only the cut-rod algorithm). Your output should be a table with n, optimal revenue, run-time.

3.) An expression of the behavior in terms of Big-O. PROVIDE PROOF/EXPLANATION

p[11] to p[40] = 30

REQUIRED OUTPUT FORMAT:

image text in transcribed

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

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions