习题-48.c
来自「本人收集的一些数据结构经典算法实现」· C语言 代码 · 共 31 行
C
31 行
//本程序只给出了算法思想
//读者可以自己完善本程序
int maxh;
Status Printpath_MaxdepthS1(Bitree T)//求深度等于树高度减一的最靠左的结点
{
Bitree pathd;
maxh=Get_Depth(T); //Get_Depth函数见6.44
if(maxh<2)
return ERROR; //无符合条件结点
Find_h(T,1);
return OK;
}//Printpath_MaxdepthS1
void Find_h(Bitree T,int h)//寻找深度为maxh-1的结点
{
path[h]=T;
if(h==maxh-1)
{
for(i=1;path[i];i++)
printf("%c",path[i]->data);
exit; //打印输出路径
}
else
{
if(T->lchild)
Find_h(T->lchild,h+1);
if(T->rchild)
Find_h(T->rchild,h+1);
}
path[h]=NULL; //回溯
}//Find_h
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?