What is wrong with my code?

#include
using namespace std;
class node{
public:
int data;
node* lt;
node* rt;
node(int d){
data=d;
lt=NULL;
rt=NULL;
}
};
node* buildbt(int pr[],int in[],int s,int e){
static int i =0;
if(s>e){
return NULL;
}
int m=-1;
for(int j=s;j<=e;j++){
if(in[j]==pr[i]){
m=j;
break;
}
}
node* rot=new node(pr[i]);
i++;
rot->lt=buildbt(pr,in,s,m-1);
rot->rt=buildbt(pr,in,m+1,e);
return rot;
}
void prntlevk(node* rot,int k){
if(rot==NULL){
return;
}
if(k==0){
cout<data<<" “;
return;
}
prntlevk(rot->lt,k-1);
prntlevk(rot->rt,k-1);
return;
}
int allnodatk(node* rot,int tg,int k){
if(rot==NULL){
return -1;
}
if(rot->data==tg){
prntlevk(rot,k);
return 0;
}
int dl=allnodatk(rot->lt,tg,k);
if(dl!=-1){
if(dl+1==k){
cout<data<<” “;
}
else{
prntlevk(rot->rt,k-2-dl);
}
return dl+1;
}
int dr=allnodatk(rot->rt,tg,k);
if(dr!=-1){
if(dr+1==k){
cout<data<<” ";
}
else{
prntlevk(rot->lt,k-2-dr);
}
return dr+1;
}
return -1;
}
int main(){
int np,ni;
cin>>np;
int pr[np];
for(int i=0;i<np;i++){
cin>>pr[i];
}
int in[np];
for(int i=0;i<np;i++){
cin>>in[i];
}
int s=0;
int e=np-1;
node* bt=buildbt(pr,in,s,e);
int t;
cin>>t;
while(t–){
int tg,k;
cin>>tg>>k;
int g = allnodatk(bt,tg,k);
if(g==-1){
cout<<0<<endl;}
else{
cout<<endl;
}
}
return 0;
}

hi @dsinght4
try this -->

its working fine but i want to know what is wrong with my code where i’m messing up

Save ur code on Coding Blocks ide and send link.

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.