Math, asked by Divyansh1355, 11 months ago

Given a set of numbers, check whether it can be partitioned into two subsets such that the sum of elements in both subsets is same or not.

Answers

Answered by Anonymous
23

 \large\boxed{\underline{\mathcal{\red{A}\green{n}\pink{s}\orange{w}\blue{e}\red{r:}}}}

Given a set of integers, the task is to divide it into two sets S1 and S2 such that the absolute difference between their sums is minimum.

If there is a set S with n elements, then if we assume Subset1 has m elements, Subset2 must have n-m elements and the value of abs(sum(Subset1) – sum(Subset2)) should be minimum.

Example:

Input: arr[ ] = {1, 6, 11, 5}

Output: 1

Explanation:

Subset1 = {1, 5, 6}, sum of Subset1 = 12

Subset2 = {11}, sum of Subset2 = 11

Answered by Anonymous
0

Answer:

Given a set of integers, the task is to divide it into two sets S1 and S2 such that the absolute difference between their sums is minimum.

If there is a set S with n elements, then if we assume Subset1 has m elements, Subset2 must have n-m elements and the value of abs(sum(Subset1) – sum(Subset2)) should be minimum.

Example:

Input: arr[ ] = {1, 6, 11, 5}

Output: 1

Explanation:

Subset1 = {1, 5, 6}, sum of Subset1 = 12

Subset2 = {11}, sum of Subset2 = 11

Similar questions