Please help me debugg my code and find why it's giving tle
There are certain errors in your code, firstly you need not to build tree using the array, since it is wrong to use this approach here, as you are given an unsorted array, Use the native approach,
if(root==NULL)
{
return new node(data);
}
if(data<=root->data)
{
root->left=insertInBST(root->left,data);
}
else
{
root->right=insertInBST(root->right,data);
}
Earlier , your code was giving runtime error, Now it is compiling successfully, but you need to make changes so as to get corrected output.