@Ravinder : Its not a DP problem.. If it was, where are the sub problems
reused or in other words, where is memoization ??
@Anchal : Its complexity is O(n^2). Look at the following segment in ur code
:
for(int i=index[n];i<sz;i++)
{
index[n+1]=i;
solve(index,arr,target,cursum+arr[i],n+1,sz);
}
Here sz is the number of elements in the array i.e. n for complexity. There
is a recursive call to solve ......
I hope its clear now .
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.