数据结构之中序穿线二叉树的构造函数:
template<typename Elemtype>
void threadtree<Elemtype>::construct_function_aux(nodepointer &p, nodepointer otherL)
{
if (otherL)
{
p = new node;
p->data = otherL->data;
p->ltag = otherL->ltag;
p->rtag = otherL->rtag;
**if(otherL->ltag==0)**
construct_function_aux(p->lchild, otherL->lchild);
**if(otherL->rtag==0)**
construct_function_aux(p->rchild, otherL->rchild);
}
}
template<typename Elemtype>
threadtree<Elemtype>::threadtree(const threadtree<Elemtype>& otherD)
{
construct_function_aux(root, otherD.root);
sequentialtothreadtree_aux2(root);
}
今天用了快一个小时寻找原来版本中出现的stack overflow 问题,最后发现,我直接用了中序穿线来拷贝初始化,没有考虑tag的问题,导致无限递归。