Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Moonbucks Coffee Shops are planning to open up new shops along a major street in San Francisco. The street has n intersections numbered consecutively from

image text in transcribed

Moonbucks Coffee Shops are planning to open up new shops along a major street in San Francisco. The street has n intersections numbered consecutively from 1 to n as you travel from North to South. Each intersection i has a projected profit of p[i] that can be earned by placing a shop at that intersection. The city law prohibits Moonbucks coffee shops to be placed at adjacent intersections. The input to the problem is the number of intersections n and the array of projected profits p[1,...,n]. Our ultimate goal is to determine a list L of intersections where Moonbucks should open up shops to maximize the total profit Lier pi). To that end, define a table C[1,..., n] such that C[j] is the maximum profit possible from the first j intersections (i.e., intersections 1 through j). (a) Specify a recurrence (including any base cases) to fill the table C defined above. Also, explain your recurrence. The explanation needn't be lengthy, but should make clear, in English, how you arrived at the base case(s) and also the general case. [8 points] Hint: similarly to a problem we studied, the general case of the recurrence involves a "binary choice" (solutions with and without the jth intersection). (b) Describe* an algorithm which efficiently (using dynamic-programming) solves the problem by using the recurrence you found in (a) to fill the table C. State any assumptions you make. [8 points] (c) Give the running time requirement for your algorithm, as a Theta...) expression, and justify it (i.e., explain in English). [4 points] * The algorithm description for (b) can be pseudocode, English descriptions, or something in between. The priority is clarity: make it clear how, and in what order, the elements of C will be determined. Moonbucks Coffee Shops are planning to open up new shops along a major street in San Francisco. The street has n intersections numbered consecutively from 1 to n as you travel from North to South. Each intersection i has a projected profit of p[i] that can be earned by placing a shop at that intersection. The city law prohibits Moonbucks coffee shops to be placed at adjacent intersections. The input to the problem is the number of intersections n and the array of projected profits p[1,...,n]. Our ultimate goal is to determine a list L of intersections where Moonbucks should open up shops to maximize the total profit Lier pi). To that end, define a table C[1,..., n] such that C[j] is the maximum profit possible from the first j intersections (i.e., intersections 1 through j). (a) Specify a recurrence (including any base cases) to fill the table C defined above. Also, explain your recurrence. The explanation needn't be lengthy, but should make clear, in English, how you arrived at the base case(s) and also the general case. [8 points] Hint: similarly to a problem we studied, the general case of the recurrence involves a "binary choice" (solutions with and without the jth intersection). (b) Describe* an algorithm which efficiently (using dynamic-programming) solves the problem by using the recurrence you found in (a) to fill the table C. State any assumptions you make. [8 points] (c) Give the running time requirement for your algorithm, as a Theta...) expression, and justify it (i.e., explain in English). [4 points] * The algorithm description for (b) can be pseudocode, English descriptions, or something in between. The priority is clarity: make it clear how, and in what order, the elements of C will be determined

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_2

Step: 3

blur-text-image_3

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

Strategic Database Technology Management For The Year 2000

Authors: Alan Simon

1st Edition

155860264X, 978-1558602649

More Books

Students also viewed these Databases questions

Question

=+What is the nature of the unions in the particular country?

Answered: 1 week ago