#include<stdio.h>
#include<stdlib.h>
struct node{
	          int data;
	          struct node* left;
	          struct node* right;
};

struct node* createnode(int val)
{
	struct node* p=(struct node*)malloc(sizeof(struct node));
	p->data=val;
	p->left=NULL;
	p->right=NULL;
	return p;
}
struct node* insertnode(struct node* root,int num)
{
	if(root==NULL)
	{
		root=createnode(num);
		return root;
	}
	if(num<root->data)
	root->left=insertnode(root->left,num);
	else
	root->right=insertnode(root->right,num);
	return root;
}
void printPreorder(struct node* root)
{
	if(root==NULL)
	return;
	printf("%d ",root->data);
	printPreorder(root->left);
	printPreorder(root->right);
}
void printInorder(struct node* root)
{
	if(root==NULL)
	return;
	printInorder(root->left);
	printf("%d ",root->data);
	printInorder(root->right);
}

void printPostorder(struct node* root)
{
	if(root==NULL)
	return;
	printPostorder(root->left);
	printPostorder(root->right);
	printf("%d ",root->data);
}

int main() {
      struct node* root=createnode(20);
      root->left=createnode(15);
      root->right=createnode(25);
      root->left->left=createnode(13);
      root->left->right=createnode(17);
      root->left->left->left=createnode(9);
      root->right->left=createnode(22);
      root->right->right=createnode(26);
      root->right->right->right=createnode(30);
      printPreorder(root);
      printf("\n");
      printInorder(root);
      printf("\n");
      printPostorder(root);
      return 0;
}
