Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following problem. Given a list of n(n even) distinct positive integers, partition the list into two sub-lists, each of size n/2, such that

Consider the following problem. Given a list of n(n even) distinct positive integers, partition the list into two sub-lists, each of size n/2, such that the difference between the sums of the integers in the two sublists is MINIMIZED. State your algorithm in no more than 4 simple sentences. do not write a pseudocode. What is the O complexity ? Here is the answer if it was MAXIMIZED: 1) find median 2) compare each element in the set with median 3) if element > median put it in set1 || if element < median put it in set2. 4) compute the sum of elements in s1 and s2: answer is A-B (Complexity os O(n)

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

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions