#include <stdio.h>
#include <stdlib.h> //without this calloc can not be used
typedef struct node //tree structure definition
{
 int data;
 struct node *left;
 struct node *right;
}branch; // here we have set it as branch

branch *createnode(int value) //createnode is the function to create a node of the tree and return it
{  
 branch *stick;
 stick=(branch *)calloc(1,sizeof(branch));
 stick->data=value;
 stick->left=NULL;
 stick->right=NULL;
 return stick;
}
void pre_order(branch *root)
{
	if(root==NULL)
	{return;}
	printf("%d ",root->data);
	pre_order(root->left);
	pre_order(root->right);

}
void post_order(branch *root)
{
	if(root==NULL)
	{return;}
	post_order(root->left);
	post_order(root->right);
	printf("%d ",root->data);
}
void in_order(branch *root)
{
	if(root==NULL)
	{return;}
	in_order(root->left);
	printf("%d ",root->data);
	in_order(root->right);
	
}
//driver program
int main(void)
{
    branch *root=createnode(2);
    root->left=createnode(5);
    root->right=createnode(1);
    root->left->left=createnode(4);
    root->left->right=createnode(9);
    root->right->left=createnode(0);
    root->right->right=createnode(6);
    printf("the preorder representation is:");
    pre_order(root);
    printf("\n the in-order representation is:");
    in_order(root);
    printf("\n the post-order representation is:");
    post_order(root);
     return 0;
}

