Question: . In a stack based template, pop function is written; find out the possible problem that may occur in this code. t pop() { t
. In a stack based template, pop function is written; find out the possible problem that
may occur in this code.
t pop()
{
t x=top->data;
if(top==NULL)
cout<< Stack underflow<
delete top; // Remove the top node
top=top->next; // move the top to the previous position
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
