You are planting tomato plants in a garden, and the garden has n spots arranged in...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You are planting tomato plants in a garden, and the garden has n spots arranged in a line. Different spots in the garden will result in different quality tomatoes: suppose that the location i will result in tomatoes of deliciousness T[i], where T[i] is a positive integer. Further, you cannot plant two plants directly next to each other, because they will compete for resources and wilt. Your goal is to create the most deliciousness possible (summed up over all of the tomato plants). For example, if the input was T = [21, 4, 6, 20, 2, 5], then you should plant tomatoes in the pattern and you would obtain deliciousness 21 +20 +5 = 46. You would not be allowed to plant tomatoes in the pattern because there are two tomato plants next to each other. In this question, you will design a dynamic programming algorithm which runs in time O(n) which takes as input the array T and returns the maximum deliciousness possible given T. Do this by answering the two parts below. (a) (3 pt.) What sub-problems will you use in your dynamic programming algorithm? What is the recursive relationship which is satisfied between the sub-problems? What is the base case for this recursive relationship? [We are expecting: ] A clear description of your sub-problems. . A recursive relationship that they satisfy, along with a base case. . An informal justification that the recursive relationship is correct. (b) (3 pt.) Write pseudocode for your algorithm. Your algorithm should take as input the array T, and return a single number which is the maximum amount of deliciousness possible. Your algorithm does not need to output the optimal way to plant the tomatoes. [We are expecting: Pseudocode AND a clear English description. You do not need to justify that your algorithm is correct, but correctness should follow from your reasoning in part (a).] You are planting tomato plants in a garden, and the garden has n spots arranged in a line. Different spots in the garden will result in different quality tomatoes: suppose that the location i will result in tomatoes of deliciousness T[i], where T[i] is a positive integer. Further, you cannot plant two plants directly next to each other, because they will compete for resources and wilt. Your goal is to create the most deliciousness possible (summed up over all of the tomato plants). For example, if the input was T = [21, 4, 6, 20, 2, 5], then you should plant tomatoes in the pattern and you would obtain deliciousness 21 +20 +5 = 46. You would not be allowed to plant tomatoes in the pattern because there are two tomato plants next to each other. In this question, you will design a dynamic programming algorithm which runs in time O(n) which takes as input the array T and returns the maximum deliciousness possible given T. Do this by answering the two parts below. (a) (3 pt.) What sub-problems will you use in your dynamic programming algorithm? What is the recursive relationship which is satisfied between the sub-problems? What is the base case for this recursive relationship? [We are expecting: ] A clear description of your sub-problems. . A recursive relationship that they satisfy, along with a base case. . An informal justification that the recursive relationship is correct. (b) (3 pt.) Write pseudocode for your algorithm. Your algorithm should take as input the array T, and return a single number which is the maximum amount of deliciousness possible. Your algorithm does not need to output the optimal way to plant the tomatoes. [We are expecting: Pseudocode AND a clear English description. You do not need to justify that your algorithm is correct, but correctness should follow from your reasoning in part (a).]
Expert Answer:
Related Book For
Introductory Statistics Exploring The World Through Data
ISBN: 9780321978271
2nd Edition
Authors: Robert Gould, Colleen Ryan
Posted Date:
Students also viewed these programming questions
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
Part A: The following departments of activities are recorded in the City of Atlantas Comprehensive Annual Financial Report in the appendix to this chapter. Indicate the type of fund that most likely...
-
Draw an acceptable Lewis electron dot diagram for these molecules that violate the octet rule. a. POF3 b. ClF3
-
How much clay must be added to 10 kg of polyethylene to produce a low-cost composite having a modulus of elasticity greater than 120,000 psi and a tensile strength greater than 2000 psi? The density...
-
Explain throttling calorimeter.
-
The accountant for Nellys Dress Shop prepared the fourth quarter 2011 cash budget that appears on the following spreadsheet. Nellys has a policy to maintain a minimum cash balance of $14,000 before...
-
Centennial Corporation produces a variety of products for industrial purposes. Typically, the markets in which they compete are very competitive. Approximately three years ago, the company's research...
-
How can unequal power distribution within teams harm the team (think about conformity and obedience)? 2. Minorities within teams and organizations can resist group pressure by being consistent,...
-
The IRR method allows a ranking of competing projects. a. True b. False
-
What does a low ratio of average reserves per well indicate?
-
How is a dry appraisal well accounted for? a. Charged to dry hole expense b. Remains capitalized so long as a subsequent appraisal well is either planned or underway c. Capitalized if other...
-
The IRR method assumes which of the following? a. All future cash inflows will be reinvested at the same rate of return as the IRR. b. None of the future cash inflows will be reinvested at the same...
-
What is the value of proved reserve additions ratio attempting to measure? How do you interpret the value of proved reserve additions ratio?
-
Describe the difference between an achievement culture and an ascription culture. How does an understanding of these differences help an international manager be effective in dealing with clients...
-
Explain how the graph of each function can be obtained from the graph of y = 1/x or y = 1/x 2 . Then graph f and give the (a) Domain (b) Range. Determine the largest open intervals of the domain over...
-
The financial statements for the business of Trinhs Nail Supplies for the past two years are presented below. Additional information 1. All purchases and sales of inventories are on credit. All...
-
The following comparative statements of financial position and statement of financial performance are for the business of Low Dollar Shop Pty Ltd. Additional information 1. All sales and purchases of...
-
The financial statements for the business of Autocare are shown below. Required (a) Prepare the statement of cash flows for Autocare for the year ended 30 June 2025, using the direct method. (b)...
Study smarter with the SolutionInn App