Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C program, 100% rate, C++ sample code: justpaste.it/5o5zr, output to whatever you like, function recursively in C, thank you. Problem 3 (48 points): Suppose

image text in transcribed

In C program, 100% rate, C++ sample code: justpaste.it/5o5zr, output to whatever you like, function recursively in C, thank you.

Problem 3 (48 points): Suppose that vou have been assigned the job of buying the plumbing pipes for a construction project Your foreman gives vou a list of the varying lengths of pipe needed, but the distributor sells stock pipe only in one fixed size. You can, however, cut each stock pipe in any way needed. Your job is to figure out the minimum number of stock pipes required to satisfy the list of requests, thereby saving money and minimizing waste. For example, if the vector contains [ 4, 3, 4, 1,7, 8 ] and the stock pipe length is 10, you can purchase three stock pipes and divide them as follows Pipe 1: 4, 4, 1 Pipe 2: 3,7 Pipe 3: 8 Doing so leaves you with two small remnants left over. There are other possible arrangements that also fit into three stock pipes, but it cannot be done with fewer. This one is tricky, and we expect you will mull over it for a while before you have a solution Here are a few hints and specifications: You may assume that all the requests are positive and do not exceed the stock length. In the worst case, you will need N stock pipes, where N is the size of the vector. You do not need to report how to cut the pipes, just the number of stock pipes needed There are several different approaches for decomposing this problem and for managing the state. As a general hint, given the current state and a request, what options do you have for satisfying that request and how does choosing that option change the state? Making a choice should result in a smaller, similar subproblem that can be recursively solved. How can you that solution to solve the larger problem? . . Grading: Comments Functioning code per requirements Well-written code Correct results, ordered output Recursion and efficiency Full submission No recursion 5 points 10 points 5 points 10 points 15 points 3 points -30 points Problem 3 (48 points): Suppose that vou have been assigned the job of buying the plumbing pipes for a construction project Your foreman gives vou a list of the varying lengths of pipe needed, but the distributor sells stock pipe only in one fixed size. You can, however, cut each stock pipe in any way needed. Your job is to figure out the minimum number of stock pipes required to satisfy the list of requests, thereby saving money and minimizing waste. For example, if the vector contains [ 4, 3, 4, 1,7, 8 ] and the stock pipe length is 10, you can purchase three stock pipes and divide them as follows Pipe 1: 4, 4, 1 Pipe 2: 3,7 Pipe 3: 8 Doing so leaves you with two small remnants left over. There are other possible arrangements that also fit into three stock pipes, but it cannot be done with fewer. This one is tricky, and we expect you will mull over it for a while before you have a solution Here are a few hints and specifications: You may assume that all the requests are positive and do not exceed the stock length. In the worst case, you will need N stock pipes, where N is the size of the vector. You do not need to report how to cut the pipes, just the number of stock pipes needed There are several different approaches for decomposing this problem and for managing the state. As a general hint, given the current state and a request, what options do you have for satisfying that request and how does choosing that option change the state? Making a choice should result in a smaller, similar subproblem that can be recursively solved. How can you that solution to solve the larger problem? . . Grading: Comments Functioning code per requirements Well-written code Correct results, ordered output Recursion and efficiency Full submission No recursion 5 points 10 points 5 points 10 points 15 points 3 points -30 points

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# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions

Question

2. Discuss the types of messages that are communicated nonverbally.

Answered: 1 week ago