Question: class _Node: Node class to create individual linked list nodes def __init__(self, element, next): self._element = element self._next = next from Node import

class _Node:
""" Node class to create individual linked list nodes """
def __init__(self, element, next):
self._element = element
self._next = next
from Node import _Node
class Stack_L:
def __init__(self):
self._L = list() # Composition: the Stack_L class has a List
def push(self, item):
pass
def pop(self):
""" Remove and returns the element at the top of stack"""
#Raises error when trying to pop from the empty stack
pass
def peek(self):
#Raises error when trying to pop from the empty stack
pass
def __len__(self):
pass
def isempty(self):
pass
class Queue_L:
def __init__(self):
self._L = []
def enqueue(self, item):
pass
def dequeue(self):
#Raises error when trying to deque from the empty queue
pass
def peek(self):
pass
def __len__(self):
pass
def isempty(self):
pass
class Stack_LL:
def __init__(self):
self._head = None
self._size = 0
def __len__(self):
""" Returns the size of the stack """
pass
def is_empty(self):
""" Returns True if the stack is empty"""
pass
def push(self, element):
""" Add "element" to the top of the stack """
pass
def pop(self):
""" Remove element from the top of the stack """
pass
def top(self):
""" Only read the element and donot remove it. """
pass
class Queue_LL:
def __init__(self):
self._head = None
self._tail = None
self._size = 0
def __len__(self):
""" Returns the size of the queue """
pass
def is_empty(self):
""" Returns True if the queue is empty"""
pass
def first(self):
""" Returns (but do not remove) the first element in the queue """
pass
def enqueue(self, element):
""" Add "element" to the back of the queue """
pass
def dequeue(self):
""" Remove element from the front of the queue """
pass
ADT. py contains skeleton code for list and linked list versions of stacks and queues. Node.py file is also provided which contains the private Node class. Using the concepts learnt from lecture, implement the stack and queue ADT using list and singly linked list. - Use test driven development (red-green-refactor) to implement the core functionalities for each class: - and for stacks and for the queues - Use lists (_L) Or linked lists (_LL ) as denoted by the class names - Include tests for each method in the public interface of each class - You can use statements or - the choice is yours
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
