PLEASE WRITE THE CODE IN PYTHON. INSTRUCTIONS AND STARTER CODE PROVIDED BELOW. Write your own Stack and Queue class, but it should use a deque instead of a Python List. It should have the following methods:
- constructor (unchanged)
- add elements to each (push() & enqueue())
- remove and return elements from each (pop() & dequeue())
- get_size() - returns the number of elements
- print_elements() - prints elements from first added to last.
main.py
1 from collections import deque
2
3 # complete the following classes
4 class Stack:
5
6 def __init__(self):
7 self.data = deque()
8
10 class Queue:
11
12 def __init__(self):
13 self.data = deque()
14