Write a recursive function which returns the count of subsequences for a given string. Print the value returned.
i m not able to make this function.
how should i approach this.
Recursion siubsequence problem question
hey @anujkurmi, if you know remember the condition of printing sub sequence, ( if(inp[i]==’\0’) ).
we usually print the output array. Here instead of printing just increment the count variable.this count should be global variable initialised with 0. At the end, count will store the number of subsequences.
but when i return the count then that count will return in between recursion also.
hey @anujkurmi, do not return the count change return type void. Now either use count as global variable whose value is changed by recursive function and main will access can the that global varible too. Or pass this count as parameter using call by reference.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.