+ 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; }

12th Feb 2019, 2:55 PM
Rohit
Rohit - avatar
1 Antwort
0
Node->right holds the address of new pointer of type struct node returned by insert function which is a recursion call
3rd Jun 2019, 2:37 PM
Vijeth Belle
Vijeth Belle - avatar