Question: I need help Writing a Python code!!! Implement an ordered list using doubly linked list Implement the following operations for an ordered list of integers

I need help Writing a Python code!!!

Implement an ordered list using doubly linked list

Implement the following operations for an ordered list of integers ordered in ascending order using a doubly linked list. The head of the list be where the smallest items are and let tail be where the largest items are. You may use whatever mechanism you like to keep track of the head and tail of the list. E.g. references or sentinel nodes. OrderedList () creates a new ordered list that is empty. It needs no parameters and returns an empty list. add (item) adds a new item to the list making sure that the order is preserved. It needs the item and returns nothing. Assume the item is not already in the list. remove (item) removes the item from the list. It needs the item and modifies the list. Return the position of removed item if it is in the list, otherwise return -1 (as not found). search_forward (item) searches for the item in the list. It needs the item and returns the boolean value True if the item is in the list and False if the item is not in the list. search_backward (item) searches for the item in the list starting from the tail of the list. It needs the item and returns the boolean value True if the item is in the list and False if the item is not in the list. is_empty () tests to see whether the list is empty. It needs no parameters and returns a boolean value. True if the list is empty and False if any items are in the list. size () returns the number of items in the list. It needs no parameters and returns an integer. index (item) returns the position of item in the list. It needs the item and returns the index. If it is not in the item it returns -1(as not found). pop () removes and returns the last item in the list. It needs nothing and returns an item. pop (pos) removes and returns the item at position pos. It needs the position and returns the item. If it is not in the item it returns -1(as not found). pop(pos) should compare pos to the size of the list and search from the head if pos <= size/2 and from the rear if pos > size/2.

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!