 Equal Sum Partition Problem

Subject Computer Science Data Structures and Algorithms

Question

Devise an algorithm to decide whether a list of integers can be divided into two smaller lists of equal sum. For instance,
[1, 1, 1,2, 2, 2, 3,3, 4, 5,16]can be fairly divided into [1, 1, 1, 2, 2, 2, 3, 3, 5] and [4, 16].
However,[4, 4, 8, 10,14]cannot be fairly divided.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

The solving idea is quite straightforward: if the sum of all elements of the array is odd, then we can’t divide the array into two subsets with equal sum; so a necessary condition is to have an even sum.
Then we can recursively try to solve the calculation of a subset with elements that sum to S/2, where S is the sum of all elements of the array. This can be achieved by trying at each step if we can include or not the last element into the target sum....

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Nondeterministic Algorithm for K-Clique Problem \$10.00
NP
Nondeterministic
Deterministic
Algorithm
K-Clique
Polynomial
Time
NP-Hard
NP-Complete
P
Computer Science
Data Structures
Randomization & Probability Questions \$18.00
Randomized
Probability
Algorithm
Dice
Conditional
False
Positive
Negative
Sum
Result
Sample
The Longest Increasing Subsequence Problem \$40.00
Programming
Computer Science
Longest Increasing Subsequence
Variables
Running Time
Algorithms
Complexity
Loops
Arrays
Algorithm Analysis, Correctness and Sorted Linked List Algorithm \$10.00
Algorithm