Why this is showing TLE?

Why this is showing TLE?

Aryan, for printing the nodes within a range … You need to use a separate function in your code as :

void printbst(node* root,int k1,int k2)
{

if(root==NULL)
{
	return;
}
if(k1<root->data)
{
    printbst(root->left,k1,k2);
}
if(k1<=root->data && k2>=root->data)
{
    cout<<root->data<<" ";
}
if(k2>root->data)
{
    printbst(root->right,k1,k2);
}

}

Mam Why my Code is wrong, I passed the given test case then it showed the correct result.

Your code is giving run error for the large test case… Thts why I prefer you to use the approach for printing as I discussed… Try to submit the code using that…