dưới đây là hàm chèn 1 node vào cây nhị phân tìm kiếm
với
khi thực hiện chạy thử thì báo lỗi là a reference of type "tree &" (not constant-qualified) cannot be initialized with a value of type "tagTnode"
Em không hiểu rõ chỗ này, mong mọi người giúp e
Code:
int insertnode(tree &t,int x) { if(t) { { if(t->data==x) return 0; if(t->data>x) return insertnode(t->pRight,x); else return insertnode(t->pLeft,x); } if(t==NULL) return -1; t->data=x; t->pLeft=t->pRight=NULL; return 1; } }
Code:
typedef struct tagTNode { int data; struct tagTnode* pLeft; struct tagTnode* pRight; }Tnode; typedef Tnode* tree;
Em không hiểu rõ chỗ này, mong mọi người giúp e
Comment