**Objective: **Given an array of integers write an algorithm to find all the subsets for which sum is equal to zero. The array contains both positive and negative integers.

**Example:**

Given Array: [8, 3, 5, 1, -4, -8], required sum: 0 Output: [-8, -4, 1, 3, 8] [-8, 3, 5] [-8, 8] [-4, 1, 3]

Given Array: [3, 1, -4, 2, 0], required sum: 0 Output: [-4, 0, 1, 3] [-4, 1, 3] [0]

**Approach:**

- Given
.*arrA[]* - Sort the
in ascending order.*arrA[]* - Start with
= 0,*currSum*= 0,*startIndex*=null*combinationList* - Iterate through
=*i*to*startIndex*.*length(arrA[])*- Add
to*arrA[i]*.*currSum* - Put
to*arrA[i]**combinationList.* - Make a recursive call with
(to process next elements) and*startIndex=i+1**combinationList.* - In tail recursion, backtrack and remove
from the*arrA[i]*to find more solutions*combinationList* - Base case: if
and*currSum=0**combinationList is not empty*.*combinationList*

- Add

**Complete Code:**

**Output:**

Given Array: [8, 3, 5, 1, -4, -8], required sum: 0 [-8, -4, 1, 3, 8] [-8, 3, 5] [-8, 8] [-4, 1, 3]

**Reference:** https://www.careercup.com/question?id=6130274301640704