Can someone please explain this code in detail? I've tried debugging it but i can't figure out how it produces the result. I've been searching for a solution for the problem and this is the code that I stumbled upon, it produces accurate solutions and I would like to know how it works. Many thanks.
I want to know how the function finds the two subsets, it works great because I've tested it for up to 300 inputs which sum adds up to 100,000.
Example: a set of numbers {1,5,9,3,8}, now the solution is two subsets, one subset with elements {9,3} and the other {8,5,1} the sum of the first one is 13 and the sum of the second is 13 so the difference between the sums is 0. The result shows the difference between the sums.
Another example: a set of numbers where the difference between the subsets cannot be zero, {9 51 308 107 27 91 62 176 28 6}, the minimal difference between the two subsets is 2.
I was going to mention this in the first post, but I tried 5,4,3,7,9 and it returned 0.
This should work because {4,3,7} = 14 and {9,5} = 14
OT/
I want to know how the function finds the two subsets,
The link I posted describes the algorithm. I can't say I understand why they did it the way it was done, but it seems to work great. Maybe someone on the forum who is good at this can explain what it does