Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started