+ 2
What actually node->right hold in node->right=insert(node->right,x)?
I was stuck in operations of binary search tree insert. See the code below.. tree *insert(tree *node,int x) { if(node==NULL) { tree *temp; temp=new tree; temp->data=x; temp->right=temp->left=NULL; return node; } if(x >(node->data)) { node->right=insert(node->right,x); } else if(x < (node->data)) { node->left=insert(node->left,x); } return node; }
1 Odpowiedź
0
Node->right holds the address of new pointer of type struct node returned by insert function which is a recursion call