Example #1
0
void DestroyBTNode(BTNode *&b)
{
	if (b != NULL)
	{
		DestroyBTNode(b->lchild);
		DestroyBTNode(b->rchild);
		free(b);
	}
}
Example #2
0
void main()
{
	BTNode *b;
	ElemType path[MaxSize],longpath[MaxSize];
	int i,longpathlen=0;
	CreateBTNode(b,"A(B(D,E(H(J,K(L,M(,N))))),C(F,G(,I)))"); 
	printf("二叉树b:");DispBTNode(b);printf("\n");
	printf("b的叶子节点:");DispLeaf(b);printf("\n");
	printf("AllPath:\n");AllPath(b);
	printf("AllPath1:\n");AllPath1(b,path,0);
	LongPath(b,path,0,longpath,longpathlen);
	printf("第一条最长逆路径长度:%d\n",longpathlen);
	printf("第一条最长逆路径:");
	for (i=longpathlen-1;i>=0;i--)
		printf("%c ",longpath[i]);
	printf("\n");
	DestroyBTNode(b);
}