is vedio m jo sir kar raha hai woh f(3) k liya apply hi nahi ho raha hai
Binary string recursion
hello @YASHMATHURIA123
consider these two base cases and the compute ur answer it will work correctly.
n==0 return 1;
n==1 return 2;
sir jab f(n)=f(n-1) +2 f(n-2) kyu ki jab hum 1 insert karenge at n position then we have to take 01 along with f(n-2) to make it valid jabhi m soch raha tha ki 2 multiply hoga aagya …
nahi 2 multiply nahi hoga.
jab 0 place hoga nth position pe tab f(n-1)
jab 1 place hoga nth posiiton pe tab f(n-2) kyunki n-1 th position pe 0 hoga.
in dono case ko combine karoge to f(n)=f(n-1)+f(n-2).
f(0)=1;
f(1)=2; { 1 , 0 }
f(2)= 3; { 00 , 01 , 10 }
f(3)=5; { 000 , 010 , 100 , 101 , 001 }