Exemplo n.º 1
0
void PrePrint(Tree T)
{
	if(T){
		printf("%c ", T->Element);
		PrePrint(T->Left);
		PrePrint(T->Right);
	}
}
Exemplo n.º 2
0
int main(void)
{
	Tree T = PreBuild();

	printf("PrePrint:\t");
	PrePrint(T);
	printf("\n");

	printf("InPrint:\t");
	InPrint(T);
	printf("\n");

	printf("InPrint_Iter:\t");
	InPrint_Iterative(T);
	printf("\n");

	printf("PostPrint:\t");
	PostPrint(T);
	printf("\n");

	printf("LevelPrint:\t");
	LevelPrint(T);
	printf("\n");

	ListDirectory(T);

	return 0;
}
Exemplo n.º 3
0
int main()
{
    StackNode *S;
    BinaryTree *B;
    S=(StackNode *)malloc(sizeof(StackNode));
    Init(S);
    B=PreCreated();
    PreOrder(B);
    PrePrint(B,S);
    printf("\n");
}
Exemplo n.º 4
0
//先序打印出从根到叶子结点的路径
void PrePrint(BinaryTree *root,StackNode *S)
{
    if(root)
    {
        ElemType e;
        Push(S,root->data);
        if(root->LChild==NULL && root->RChild==NULL)
        {
            Pop(S,&e);
            printf("\n%c:",e);
            PrintStack(S);
        }
        else
        {
            PrePrint(root->LChild,S);
            PrePrint(root->RChild,S);
            Pop(S,&e);
        }
    }
}