void travWithStack(TNP1 head)
{
SNptr s=initStack();
push(s,head);
TNP1 p=head;
while(!stackEmpty(s) || p)
{
while(p)
{
push(s,p);
p=p->left;
}
if(!stackEmpty(s))
{
p=pop(s);
printf("%d ",p->key);
p=p->right;
}
}
}
算法导论 练习题 10.4-3
最新推荐文章于 2021-07-14 10:16:26 发布