My code is correct for sample input and test case 0 but shows run time error on rest test cases

only one condition left which is
in delete function
if(root==NULL)return NULL;
also in constructor of node
node(int x)
{
val=x;
left=NULL;
right=NULL;
}

now all testcases pass

i hope this help
if you have more doubts regarding feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course