Professional Documents
Culture Documents
}
else
temp=temp->right;
}//else
}//while
}//else
}//create
void push(struct stack**top,struct BST*t)
{
struct stack*new=(struct
stack*)malloc(sizeof(struct stack));
if(new==NULL)
{
printf("\n stack overflow");
return;
}
new->t=t;
new->next=(*top);
(*top)=new;
}
int isempty(struct stack*top)
{
return(top==NULL)?1:0;
}
struct BST* pop(struct stack**top)
{
struct BST *res;
struct stack *top1;
if(isempty(*top))
printf("\n stack underflow");
else
{
top1=*top;
res=top1->t;
*top=top1->next;
free(top1);
return res;
}
}
void inorder(struct BST *root)
{
struct BST *cur=root;
struct stack *s=NULL;
while (1)
{
menu options
1.Create
2.inorder
3.exit
enter ur choice1
enter integer value:
43
enter ur choice1
enter integer value:
20
enter ur choice1
enter integer value:
56
enter ur choice1
enter integer value:
15
enter ur choice1
enter integer value:
18
enter ur choice1
enter integer value:
45
enter ur choice1
enter integer value:
65
enter ur choice2
inorder Traversal
15
18
20
43
45
56
enter ur choice3
[13r21a0507@mysqldbserver week6]$
65