STACK
IMPLEMENTATAION:
top=-1;
int stack[MAX];
void push(int element)
{
if(top==(MAX-1))
{
printf(“Stack
overflow!\n”);
return;
}
else
{
top++;
stack[top]=element;
}
}
int pop()
{
int
data;
if(top==-1)
{
printf(“Stack
underflow!\n”);
return;
}
else
{
data=stack[top];
top--;
return data;
}
}
No comments:
Post a Comment