Professional Documents
Culture Documents
}//else
}//while
}//else
}//create
void postorder(struct BST *temp)
{
if(temp!=NULL)
{
postorder(temp->left);
postorder(temp->right);
printf("\t%c",temp->data);
}
}
int main()
{
int ch;
printf("\nmenu options\n");
printf("1.Create\n2.Postorder\n3.exit\n");
while(1)
{
printf("\nenter ur choice");
scanf("%d",&ch);
switch(ch)
{
case 1:create();
break;
case 2:printf("Postorder
Traversal\n");
postorder(root);
break;
case 3:exit(0);
default:printf("invalid
choice\n");
}//switch
}//while
}//main
Output:
$ ./a.out
menu options
1.Create
2.Postorder
3.exit
enter ur choice1
enter character:
E
enter ur choice1
enter ur choice1
enter character:
F
enter character:
C
enter ur choice1
enter ur choice1
enter character:
B
enter character:
A
enter ur choice1
enter character:
G
enter ur choice1
enter ur choice2
Postorder Traversal
A
C
B
E
G
F
D
enter ur choice3
[13r21a0507@mysqldbserver week5]$