Solution: The Partition Problem
This review provides a detailed analysis of the ways to solve the partition problem.
Solution #1: Brute force
Let’s start by looking at the brute force solution to solve this problem first:
Explanation
This problem is very similar to the 0/1 knapsack. It essentially follows the same pattern. This solution tries all the combinations of partitioning the given numbers into two sets to see if any pair of sets have an equal sum.
If represents the total sum of all the given numbers, then the two equal subsets must have a sum equal to . So, our problem is technically to find a subset of the given numbers that has a total sum of ...