Code 3-10-2020
Code 3-10-2020
h>
#include<stdlib.h>
#include<math.h>
struct node
{
struct node *left;
struct node *right;
char data;
};
struct node *create()
{
int choice;
struct node *nn;
nn=(struct node *)malloc(sizeof(struct node));
printf("Enter the data ");
scanf(" %c",&nn->data);
nn->left=NULL;
nn->right=NULL;
printf("Press 1 if %c has left node\nPress 0 otherwise",nn->data);
scanf("%d",&choice);
if(choice)
{
nn->left=create();
}
printf("Press 1 if %c has right node\nPress 0 otherwise",nn->data);
scanf("%d",&choice);
if(choice)
{
nn->right=create();
}
return nn;
}
void postorder(struct node *root)
{
if(root==NULL)
return;
else
{
postorder(root->left);
postorder(root->right);
printf("%c",root->data);
}
}
int main()
{
struct node *root;
root=create();
postorder(root);
return 0;
}