Question: python please Write a Python implementation of the Stack class using a linked list. The file Stack.py contains the specification of the Stack ADT. In
Write a Python implementation of the Stack class using a linked list. The file Stack.py contains the specification of the Stack ADT. In class, we looked at a Stack implementation using a Python list. The implementation for this assignment should be based on a linked list. You will need to import the ListNode class from ListNode.py to use in the Stack implementation. A Stack object should have a member variable self.head that is a reference to the first ListNode object in the object, and a member variable self.count that is the number of items in the Stack object. The constructor should create an empty list, so it should set the values of those member variables correctly for an empty list. Implement the other functions - push, pop, top, and size - appropriately for a linked list version of a Stack. The function push should place a new item at the head of the list. The function pop should remove the node that is at the head of the list and return the item there. The function top should return the item from the node at the head of the list without removing the node. The function size should return the number of items in the Stack. A test program for this class will be posted. Your submission of the completed assignment will have two files - the Stack implementation and the results from the Python shell showing that your Stack passes all the tests in the test file. Submit them through Blackboard by the end of the day on November 2, 2022. Please be sure to include your name in the Stack implementation file as a comment
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
