void SBT_InorderPrintTree(SBTNode* Node)
{
	if (Node == NULL)
		return;

	/*  왼쪽 하위 트리 출력 */
	SBT_InorderPrintTree(Node->Left);

	/*  루트 노드 출력 */
	printf(" %c", Node->Data);

	/*  오른쪽 하위 트리 출력 */
	SBT_InorderPrintTree(Node->Right);
}
int main(void)
{
	SBTNode* A = SBT_CreateNode('A');
	SBTNode* B = SBT_CreateNode('B');
	SBTNode* C = SBT_CreateNode('C');
	SBTNode* D = SBT_CreateNode('D');
	SBTNode* E = SBT_CreateNode('E');
	SBTNode* F = SBT_CreateNode('F');
	SBTNode* G = SBT_CreateNode('G');

	A->Left = B;
	B->Left = C;
	B->Right = D;

	A->Right = E;
	E->Left = F;
	E->Right = G;

	printf("Preorder ...\n");
	SBT_PreorderPrintTree(A);
	printf("\n\n");

	printf("Inorder ...\n");
	SBT_InorderPrintTree(A);
	printf("\n\n");

	printf("Postorder ...\n");
	SBT_PostorderPrintTree(A);
	printf("\n\n");

	SBT_DestroyTree(A);

	return 0;
}
Example #3
0
int main( void )
{

	
    /*  노드 생성 */
    SBTNode* A = SBT_CreateNode('A');
    SBTNode* B = SBT_CreateNode('B');
    SBTNode* C = SBT_CreateNode('C');
    SBTNode* D = SBT_CreateNode('D');
    SBTNode* E = SBT_CreateNode('E');
    SBTNode* F = SBT_CreateNode('F');
    SBTNode* G = SBT_CreateNode('G');
    printf(" %c",'a');
    /*  트리에 노드 추가 */
    A->Left  = B;
    B->Left  = C;
    B->Right = D;

    A->Right = E;
    E->Left  = F;
    E->Right = G;
    
    /*  트리 출력 */
    printf("Preorder ...\n");
    SBT_PreorderPrintTree( A );
    printf("\n\n");

    printf("Inorder ... \n");
    SBT_InorderPrintTree( A );
    printf("\n\n");

    printf("Postorder ... \n");
    SBT_PostorderPrintTree( A );
    printf("\n");

    /*  트리 소멸시키기 */
    SBT_DestroyTree( A );
	getchar();
    return 0;
}