linked lists class linkedstack """lifo stack implementation using singly linked list for storage "" nested node class class node """lightweightnonpublic class for storing singly linked node ""slots _element _next streamline memory usage initialize node' fields def init (selfelementnext)reference to user' element self element element reference to next node self next next stack methods def init (self) """create an empty stack ""reference to the head node self head none number of stack elements self size def len (self) """return the number of elements in the stack "" return self size def is empty(self) """return true if the stack is empty "" return self size = def push(selfe) """add element to the top of the stack ""create and link new node self head self node(eself head self size + def top(self) """return (but do not removethe element at the top of the stack raise empty exception if the stack is empty "" if self is empty) raise emptystack is empty top of stack is at head of list return self head element code fragment implementation of stack adt using singly linked list (continued in code fragment