Sir I am sharing my code with you. The subsequences generated are the same but their sequence is different. It’s because I have started to decrease the size from the end rather than from the beginning. My answer is also correct. Could you please tell me what to do now.
Recursion- Subsequences
Priyanshi, for printing the subsequences in the required fashion, the approach you have used will not be used, instead, you have to take two strings as parameter, one is the input string and other as null string initially, as void printsubsequences(string str,string osf) and then your base case will be,
if(str.length()==0)
{
cout<<osf<<" ";
return;
}
char ch=str[0]; // this line will be the first letter or character of your string, so you will calculate the one recursive call using that character and one without using that character…
string ros=str.substr(1); // substring function is inbuilt function in which you will generate the left over string after you had first character…
printsubsequences(ros,osf);
printsubsequences(ros,osf+ch);