⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 习题-48.c

📁 本人收集的一些数据结构经典算法实现
💻 C
字号:
//本程序只给出了算法思想
//读者可以自己完善本程序
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -