Optimal Binary Strings Recursion

Ques —> Count binary strings of length N which have no consecutive ones

I couldn’t understand the solution and code for this, please explain it using recursion.

Hello @Subrat in this problem u need to tell the count of n length binary string which have no consecutive one.

for example if n=3
then all 3 length string are ->
000
001
010
011
100
101
110
111

total 8 , 3 length strings but 3 of them have consecutive ones(011,110,111) so we wont count them
hence our answer will be 5
for this implementation we have to code:


as the pattern in the output is fibonacci one so we can do this with fibonacci question in which we are calculating the sum previous 2 terms and current ans will be the sum of the previous subsequent 2 terms.

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.