def pop(self)"""remove and return the element from the top of the stack ( liforaise empty exception if the stack is empty ""if self is empty)raise emptystack is empty answer self head element bypass the former top node self head self head next self size - return answer code fragment implementation of stack adt using singly linked list (continued from code fragment when implementing the top methodthe goal is to return the element that is at the top of the stack when the stack is emptywe raise an empty exceptionas originally defined in code fragment of when the stack is nonemptyself head is reference to the first node of the linked list the top element can be identified as self head element our implementation of pop essentially mirrors the pseudo-code given in code fragment except that we maintain local reference to the element that is stored at the node that is being removedand we return that element to the caller of pop the analysis of our linkedstack operations is given in table we see that all of the methods complete in worst-case constant time this is in contrast to the amortized bounds for the arraystack that were given in table operation push(es pops toplen(ss is emptyrunning time ( ( ( ( ( table performance of our linkedstack implementation all bounds are worstcase and our space usage is ( )where is the current number of elements in the stack