Recursion-Subsequences Doubt1

I am able print the number of substrings correctly but the substrings are not printed in the output. Please help.

In order to print the string in order from d to abcd, it is more convenient to use strings, instead of char array, Try using that approach in your code for the same.

subseq(c,d,i+1,j+1);
subseq(c,d,i+1,j);

If I write this, then the sub-sequences are printed in reverse order as per required output, but after
subseq(c,d,i+1,j);
subseq(c,d,i+1,j+1);

writing this, then no output prints out. I am confused with this point.

I have modified your code a little bit, based on approach I have told above , plz refer to the code,

1 Like

can you please explain me how this code is working as i am not getting it

Basically in a string, for generating the subsequences, you will either include a particular character or not include a particular character, and then you will call recursion to do the same work for rest of the string, i.e the substring function will be used to calculate the rest of the string ( ros )…

mam can u please tell me whats wrong with my code???

I have the same doubt…can anyone please clear this?