Showing time limit error..please help me reduce the time conplexity

#include
using namespace std;
int binarystrings(char *arr,int n,int i)
{
if(i==n)
{
arr[i]=’\0’;
return 1;
}
if(arr[0]==’\0’)
{
arr[0]=‘0’;
int ans=binarystrings(arr,n,i+1);

arr[0]=‘1’;
int ans1=binarystrings(arr,n,i+1);
return ans+ans1;
}
if(arr[i-1]!=‘1’)
{
arr[i]=‘0’;
int a=binarystrings(arr,n,i+1);
arr[i]=‘1’;
int b=binarystrings(arr,n,i+1);
return a+b;
}
else
{
arr[i]=‘0’;

int a=binarystrings(arr,n,i+1);
return a;

}

}
int main() {
int t;
cin>>t;
int q=1;
int n;
while(q<=t)
{ cin>>n;
char arr[n+1];
arr[0]=’\0’;
int ans=binarystrings(arr,n,0);
cout<<ans<<endl;
q++;

}
return 0;
}

if you watch the series , you will find it as a fibonacci series with dp[1]=2 and dp[2]=3 , and dp[n]=dp[n-1] + dp[n-2] .
We can append either 0 or 1 to a string ending in 0, but we can only append 0 to a string ending in 1.
Let a[i] be the number of binary strings of length i which do not contain any two consecutive 1’s and which end in 0. Similarly, let b[i] be the number of such strings which end in 1.
this yields the above recurrence.

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.