Examveda

Which of the following should be the base case for the recursive solution of subset sum problem?

A.

if(sum==0)
return true;

B.

if(sum==0)
   return true;
if (n ==0 && sum!= 0) 
   return false; 

C.

if (n ==0 && sum!= 0) 
return false; 

D.

if(sum<0)
   return true;
if (n ==0 && sum!= 0) 
   return false; 

Answer: Option B


This Question Belongs to Data Structure >> Miscellaneous On Data Structures

Join The Discussion

Related Questions on Miscellaneous on Data Structures