首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

指针引用和指针的区别!关于线索二叉树的有关问题

2012-04-12 
指针引用和指针的区别!关于线索二叉树的问题typedef struct BiThrNode{TElemType datastruct BiThrNode *

指针引用和指针的区别!关于线索二叉树的问题
typedef struct BiThrNode
{
TElemType data;
struct BiThrNode *lchild,*rchild;
int LTag,RTag;
}BiThrNode,*BiThrTree;

为什么void InThreading(BiThrTree p)不是指针引用!他不是要修改叶子结点的左右孩子指向么?

void InThreading(BiThrTree p)//中序遍历二叉树
{
if(p)
{
InThreading(p->lchild);//左子树线索化
if(!p->lchild)//前驱线索
{
p->LTag=Thread;
p->lchild=pre;
}
if(!pre->rchild)//后继线索
{
pre->RTag=Thread;
pre->rchild=p;
}
pre=p;//保持pre指向p的前驱
InThreading(p->rchild);//右子树线索化
}
}

[解决办法]
BiThrTree 不就是个指针类型吗?InThreading(BiThrTree p)里p就是一个指针。InThreading里修改p所指向的内容,不就已经改到了给它的参数所指向的内容了吗?

热点排行