Question: In this assignment, you will implement a double-ended queue (deque) using a doubly-linked list. You may use the code from hw4-skeleton.py on Piazza as a

 In this assignment, you will implement a double-ended queue (deque) usinga doubly-linked list. You may use the code from "hw4-skeleton.py" on Piazzaas a starting point. The "hw4-skeleton.py" module defines a Node class anda Deque class. The Node class is complete and ready to use.Several methods for Deque are already implemented for you, but you will

In this assignment, you will implement a double-ended queue (deque) using a doubly-linked list. You may use the code from "hw4-skeleton.py" on Piazza as a starting point. The "hw4-skeleton.py" module defines a Node class and a Deque class. The Node class is complete and ready to use. Several methods for Deque are already implemented for you, but you will need to implement the remaining methods. (The pre-implemented methods may not work properly until you provide working implementations for the missing methods.) Note that the __iter__() and __reversed__() methods are implemented assuming a double-linked list, but that the linked list is not circular. That is, the "head" and "tail" nodes are not directly linked with each other. That is, head.getprev() and tail.getnext() both return None. Please review the course slides for the definition of a double-ended queue (deque) data structure. A working example of a singly-linked list can also be found in the course notes. For a deque, don't forget to consider both the "head" and "tail" when updating the object! Also note that for a length-one deque, the head and the tail will be the same node. A class for a node in a doubly-linked list, storing a data payload and links to next and previous nodes. IIIII Deque: \#\#\# Problem 5 def find(self, value): Finds the index of the given value in the deque. param value: The value to search for in the deque. returns: The index of the value if it exists; otherwise, None. pass Problem 5 Define the method Deque.find(self, value) satisfying the following criteria: - Find and return the index (as an offset) of the given value in the deque - If the value does not exist in the deque, return None Examples: In : y= Deque () In : y.push_back (1.11) In : y.push_back (2.22) In : y.push_back (3.33) In : print(y) 1.112.223.33 In : yfind(1.11) Out: 0 In : y.find(2.22) Out: 1 In : y.find("a") \# returns None (not printed)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!