Please see the question statement BST Operations

Approach 1: I am calculating position in recursion - Submission Link

This passes sample test but gives WA.

```
node* insert(node *root,int key){
if(root==NULL) return new node(key);
if(key<root->key){
root->left=insert(root->left,key);
root->left->pos=2*(root->pos);
}
else if(key>root->key){
root->right=insert(root->right,key);
root->right->pos=2*(root->pos) + 1;
}
else return root;
return root;
}
```

Approach 2: I pass correct position as argument in recursion calls. This is accepted. Submission Link

```
node* insert(node *root,int key,int pos){
if(root==NULL) return new node(key,pos);
if(key<root->key){
root->left=insert(root->left,key,2*pos);
}
else if(key>root->key){
root->right=insert(root->right,key,2*pos+1);
}
else return root;
return root;
}
```

I have to make changes to print the position accordingly in both approaches as well. Could that be the problem?

Could anyone please tell me why approach one could be giving WA? I know it is not the most efficient logic yet I want to understand the underlying mistake.