Question: PYTHON Instead of using an array, as the StackLab did, here you will use a Linked List from your language's library. Implement all the methods
PYTHON
Instead of using an array, as the StackLab did, here you will use a Linked List from your language's library. Implement all the methods of Stack : push(), pop(), size(), printStackDown(), etc, using calls to the linked list methods that correspond to the actions need. In the array implementation, you wrote code to manipulate the array. For this linked list implementation, methods already exist. You do not need maxSize, comment this out and explain why it's not needed. You do not need top, comment this out and explain why it's not needed. Before the underlying implementation of stack was array, now the underlying implementation of stack will be Linked list. Submit all the source files here.
class Stack: def __init__(self, max_size=5): self.top = -1 self.max_size = max_size self.items = ["" for x in range(max_size)] def is_empty(self): def is_full(self): def push(self, item): def pop(self): def peek(self): def size(self): def print_stack_up(self): stack_str = "" return stack_str;
class StackEmptyException(Exception): pass
class StackFullException(Exception): pass
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
