retagged by
2,010 views

1 Answer

1 votes
1 votes

Let isSubSetSum(int set[], int n, int sum) be the function to find whether there is a subset of set[] with sum equal to sum. n is the number of elements in set[].

The isSubsetSum problem can be divided into two subproblems
…a) Include the last element, recur for n = n-1, sum = sum – set[n-1]
…b) Exclude the last element, recur for n = n-1.
If any of the above the above subproblems return true, then return true.

and the amount of work done is O(2N)

so from that work done , i guess the brute force complexity will be D

Related questions

0 votes
0 votes
1 answer
1