Optimal binary string recursion

why do you suppose in the case of one that the next number should be always one?
so that the we make the next call by passing (n-2)
it might be possible that the next number to be 0?!

hello @mzk1994

yeah thats why we broke it into two cases.
a) we place 0 at nth place so simply we can call f(n-1)
b) we place 1 at nth place,then clearly we cannot place 1 again at n-1 th place becuase two consecutive 1’s not allowed. that means at n-1th place we will always have 0.
and becuase values at n and n-1 position are already fixed, we will call on remaining f(N-2)

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.