Not getting the expected output
take two variables size and sum
set intially both to zero
now process elements using recursion
// base case:
if(sum==0&&size>0) return true;
if(i==n)return false;
case 1: consider the element into subset
return rec(arr,i+1,sum+arr[i],size+1);
case 2: doesn’t consider the element
return rec (arr,i+1,sum,size)
this is basic structure of recursive function
i hope this helps
The mistake in ur approach, u set sum as zero so when it comes into the recursive case, it does not satisfy until i==n
but at any point when i ==n
it will satisfy irrespective of whether it is true or not
so that is wrong