void binaryTreePrintInOrder(Node *node){

	if(node != NULL){
		binaryTreePrintInOrder(node->left);
		printf("data : %d \n", node->data);
		binaryTreePrintInOrder(node->right);
	}
}
Beispiel #2
0
void binaryTreePrintInOrder(Node *node)
{
    if(node != NULL)
    {
        binaryTreePrintInOrder(node->left);
        display(node->data);
        printf("%d ", node->data);
        binaryTreePrintInOrder(node->right);
    }
}
/**
*		10
*	   /   \
*	  5    15
*/
void test_binaryTreePrintInOrder_5_10_15(void){
	
	Node Child15 = {NULL, NULL, 15};
	Node Child5 = {NULL, NULL, 5};
	Node root = {&Child5, &Child15, 10};
	
	printf("test_binaryTreePrintInOrder_5_10_15\n");
	binaryTreePrintInOrder(&root);

}
/**
*		10
*		/ \
*	   5   -
*	  / \
*	 1   -
*/
void test_binaryTreePrintInOrder_1_5_10(void){
	
	Node Child1 = {NULL, NULL, 1};
	Node Child5 = {&Child1, NULL, 5};
	Node root = {&Child5, NULL, 10};
	
	printf("test_binaryTreePrintInOrder_1_5_10\n");
	binaryTreePrintInOrder(&root);

}
Beispiel #5
0
void printLinear(Node *node)
{
    if(node != NULL)
    {
        binaryTreePrintInOrder(node->left);
        display(node->data);
        printf("%d ", node->data);
    }
    printf("\n");
}
/**
*		10
*	  /  	 \
*	 5  	 15
*	/  \ 	 / \
*  1	6  	12  17
*/
void test_binaryTreePrintInOrder_1_5_6_10_12_15_17(void){
	
	Node Child17 = {NULL, NULL, 17};
	Node Child12 = {NULL, NULL, 12};
	Node Child15 = {&Child12, &Child17, 15};
	
	Node Child1 = {NULL, NULL, 1};
	Node Child6 = {NULL, NULL, 6};
	Node Child5 = {&Child1, &Child6, 5};
	Node root = {&Child5, &Child15, 10};
	printf("test_binaryTreePrintInOrder_1_5_6_10_12_15_17\n");
	binaryTreePrintInOrder(&root);

}
/**
 *               10
 *              /  \
 *             5    15
 *            / \   / \
 *           3  -  12
 *
 */
void test_binaryTreePrintInOrder_given_5_nodes_should_print_3_5_10_12_15()
{
    printf("test_binaryTreePrintInOrder_given_5_nodes_should_print_3_5_10_12_15\n\n");
    
    Node left_leftgrandChild    = {NULL,NULL,3};
    Node right_leftgrandChild   = {NULL,NULL,12};
    Node rightChild             = {&right_leftgrandChild,NULL,15};
	Node leftChild              = {&left_leftgrandChild,NULL,5};
    Node root                   = {&leftChild,&rightChild,10};


    binaryTreePrintInOrder(&root);
    printf("\n______________________________________________________\n\n");

}