Question: c++ Write a recursive solution to solve the Partition problem. Partition: Given a set A of n integers a, a,, ..., an, can you find
Write a recursive solution to solve the Partition problem. Partition: Given a set A of n integers a, a,, ..., an, can you find a subset A, of integers such that the sum of the integers in A, is half of the sum of all the n integers (that is, Zaied, a; = Lied 4.)? Input: 1. Number of integers of set A:n 2. n integers: a, a, ..., a. Output: Print out yes if you can find a subset A, of integers such that the sum of the integers in A, is half of the sum of all the n integers (that is, Lates, a = Caiena:); otherwise, print out no, Test your program with the following two instances: I 1) 5 integers: 5, 10, 6, 8, 1 2) 20 integers: 1, 5, 7, 34, 76, 54, 23, 19, 22, 81, 44, 77, 29, 40, 11, 42, 43, 31, 57, 61
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
