Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can you solve the code using C++? You are organizing the perfect party and you are given a list A of people that can potentially

image text in transcribed

can you solve the code using C++?

You are organizing the perfect party and you are given a list A of people that can potentially attend the party. Each person in the list is assigned a positive integer (between 1-100) that rates how much this person can contribute to the success of the party. However, the list is organized in such a way such that if you select the i-th person from the list to attend the party then you cannot select any of its neighbors because they do not mix well with each other. So, given the list and the ratings of the people, come up with a Divide & Conquer algorithm that returns the maximum sum achieved by people that can attend, subject to the constraint mentioned above. For example if the list of ratings is 7, 3, 5, 8, 2, 1, 2, 3, th the best sum is 19, achieved by the underlined numbers. (a) (3 points) Suppose you divide the list into parts L, R of size n/2 (assume n is a power of 2) and you compute best sum of ratings that can be achieved recursively for each part. Then simply return the sum of these numbe Does this solve the problem? Explain why or why not. Now present your own D&C approach, again splitting the input in half. you need to: (b) Give a high level description of your algorithm. (C) Show how you handle the base cases. (d) Explain carefully why your algorithm is correct. Justify the recurrence T(n) of its running time and solve it using any method we learned in class. (f) Implement your algorithm and run it on the test instances shown in the web page. Sh screenshots of its execution. Hint: Your D&C algorithm should return additional values. The running time should be linear, given by the expressi T(n) = 2T(n/2) + O(1)

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

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions