Question
PYTHOn 3 PLEASE COMPLETE CODE #COMMENTS APPRECIATED Problem A Deque (pronounced like a deck) is short for a Double Ended Queue, which means it's a
PYTHOn 3
PLEASE COMPLETE CODE
#COMMENTS APPRECIATED
Problem
A Deque (pronounced like a "deck") is short for a Double Ended Queue, which means it's a queue that allows us to add/remove items from both the front and the back (as opposed to only adding things to the back of the queue, and removing them from the front of the queue).
We want to use a LinkedList to implement a Deque with the four main operations shown in the code. Use the example in the comments to figure out the behavior of the Deque.
All four operations of the Deque should perform in O(1).
CODE FROM PIC:?
class Deque: def __init__(): # TODO initialize the Linked List here def enqueue(self, item): # TODO normal enqueue operation def dequeue(self): # TODO normal dequeue operation def enqueue_front(self, item): # TODO places the given item at the front of the queue # (i.e. ahead of everyone else in the line) def dequeue_back(self): # TODO removes the item at the back of the queue # (i.e. the item that was most recently inserted by dequeue())?
Instructions from your teacher Lass Deque: 2 def init O: Problem # TODO initialize the Linked List here A Deque (pronounced like a "deck") is short for a Double Ended Queue, which means it's a queue that allows us to add/remove items from both the front and the back (as opposed to only adding things to the back of the queue, and removing them from the front of the queue) 5 def enqueue(self, item): # TODO normal enqueue operation We want to use a LinkedList to implement a Deque with the four main operations shown in the code. Use the example in the comments to figure out the behavior of the Deque. 8 def dequeue(self): # TODO normal dequeue operation All four operations of the Deque should perform in O(1). 10 11def enqueue front(self, item): 12 # TOD0 places the given item at the front of the queue # (i.e. ahead of everyone else in the line) 15 def dequeue_back(self): # TOD0 removes the item at the back of the queue # (i.e. the item that was most recently inserted by dequeue()) 17Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started