构建带父结点的二叉树,并输出全部结点到根结点的路径

在构建好二叉树后,须要经过一次遍从来给每一个结点的parent赋值,关键代码以下:ios void triBtee(BTNode *p,BTNode *q)//给各个结点的parent赋值 { if(p == nullptr) return; p->parent = q; q = p; triBtee(p->left,q); triBtee(p->right,q); } void
相关文章
相关标签/搜索