Hi there all. We are doing binary search trees. I'm having a little bit of trouble here though. Okay I need to as a few questions though.
here is the code observe
with all of that being said what do you think I can do with this to make these functions run correctlyCode:#include <iostream> using namespace std; struct node { int info; node *left; node *right; }; node *root=new(node); //why declare root as a new node? inorder(node); //is this the correct syntax for declaring the function? insert(node *p, int x); //for user defined functions using pointers? void insert(node *&p, int x) { if(p==NULL) { p=new(node); //if root has been declared why make a p->info=x; //a new node in the insert function p->left=NULL; p->right=NULL; } else if(x < p->info) { insert(p->left, x); } else insert(p->right, x); void inorder(node *p) { if(p!=NULL) { inorder(p->left); cout<<p->info; inorder(p->right); } } void main() { insert(root); } }