Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE SOLVE QUESTION (f) with these instances test using C code You are organizing the perfect party and you are given a list A of

image text in transcribed

PLEASE SOLVE QUESTION (f) with these instances test using C code

image text in transcribed

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). , Test your algorithm with the following instances: = N=10 A[] = {6, 8, 2, 6, 18, 6, 3,1,4,10} Best sum is 31 N-22 A[] = 19, 18, 6, 7,5, 8, 1, 16,17,6,16, 5, 20, 3,6,7,3, 2, 1, 19 Best sum is 125 N-8 AI] = 8,8,28, 9,42, 22,12, 100, 56, 2,74,12,23,81,99,47,40,49,9 1,2,3,6,6,7,6,74,56,59,2,34} Best sum is 884 A[] = 9,8,82,58,64,69,27,76,96,21,85,4,13,96,92,60,42,67,84 ,52, 3, 2, 9, 5,3,2,14,3,29, 20,98,88,73,72,35,26,53,1,89, 3 9,24,8,9,47,4,67,8,74,76,83} Best sum is 1559 18 A[] = {4,8,27,53,45,100,28,41,8,39,95,27,70,93,77,9,42,9,18, 38, 2,78,26,43,17,22,57,57, 3,65,52, 94,11,30,90, 57,98,25,43,2 3,61,94,67,8,25,3,74,77,24,39,15,15,35,6,67,43,53,36,6,40 ,71,19,5,8,82,52,6,92,25,1,57,16,52, 25, 28,21,39,62,62,98, 55,74,16,29,9,66,41,51,17,26,93,86,14,9,45,63,35,51,13, 100} Best sum is 2915

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 2 Lnai 9285

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Joao Gama ,Alipio Jorge ,Carlos Soares

1st Edition

3319235249, 978-3319235240

More Books

Students also viewed these Databases questions

Question

4. How could you face and handle a similar challenge in the future?

Answered: 1 week ago

Question

How can we visually describe our goals?

Answered: 1 week ago

Question

What metaphors might describe how we work together?

Answered: 1 week ago

Question

What are some of the possible scenes from our future?

Answered: 1 week ago