数据结构 二叉树定义问题
btree *insert_node(btree *root,int node){
btree *newpointer;
btree *currentpointer;
btree *parentpointer;
newpointer=(btree*)malloc(sizeof(btree));
newpointer->data=node;
newpointer->lchild=NULL;
newpointer->rchild=NULL;
if(root==NULL)
{
return newpointer;
}
else
{
currentpointer=root;
while(currentpointer!=NULL)
{
parentpointer=currentpointer;
if(currentpointer->data>node)
{
currentpointer=currentpointer->lchild;
}
else
{
currentpointer=currentpointer->rchild;
}
}
if(parentpointer->data>node)
{
parentpointer->lchild=newpointer;
}
else
{
parentpointer->rchild=newpointer;
}
return root;
}
}
btree *create_btree(int data[],int len)
{
int i;
btree *root=NULL;
for(i=0;i<len;i++)
{
root=insert_node(root,data[i]);
}
return root;
}
显示 处未处理的异常: 0xC0000005:
Bitree.exe 中的 0x00414c5e 处最可能的异常: 0xC0000005: 读取位置 0xccccccd0 时发生访问冲突
Bitree.exe 中的 0x00414c5e 处未处理的异常: 0xC0000005: 读取位置 0xccccccd0 时发生访问冲突
程序“[4012] Bitree.exe: 本机”已退出,返回值为 0 (0x0)。