step allocate memory for the new node and name it as new_node step set new_node -data val step if top null set new_node -next null set top new_node else set new_node -next top set top new_node [end of ifstep end is done by checking if top null in case the if statement evaluates to truethen null is stored in the next part of the node and the new node is called top howeverif the new node is not the first node in the listthen it is added before the first node of the list (that isthe top nodeand termed as top pop operation the pop operation is used to delete the topmost element from stack howeverbefore deleting the valuewe must first check if top=nullbecause if this is the casethen it means that the figure algorithm to insert an element in stack is empty and no more deletions can be done if an linked stack attempt is made to delete value from stack that is already emptyan underflow message is printed consider the stack shown in fig top figure linked stack in case top!=nullthen we will delete the node pointed by topand make top point to the second element of the linked stack thusthe updated stack becomes as shown in fig step if top null print "underflowgoto step [end of ifstep set ptr top step set top top -next step free ptr step end figure algorithm to delete an element from linked stack figure linked stack after deletion of the topmost element figure shows the algorithm to delete an element from stack in step we first check for the underflow condition in step we use pointer ptr that points to top in step top is made to point to the next node in sequence in step the memory occupied by ptr is given back to the free pool programming example top write program to implement linked stack ##include #include #include #include struct stack int datastruct stack *next}struct stack *top nullstruct stack *push(struct stack *int)struct stack *display(struct stack *)struct stack *pop(struct stack *)int peek(struct stack *)int main(int argcchar *argv[]int valoption