Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

class NodeDLL: def __init__(self, init_data, next_node=None, prev_node=None): self.data = init_data self.next = next_node self.prev = prev_node def get_data(self): return self.data def get_prev(self): return self.prev def

class NodeDLL:

 def __init__(self, init_data, next_node=None, prev_node=None): self.data = init_data self.next = next_node self.prev = prev_node def get_data(self): return self.data def get_prev(self): return self.prev def get_next(self): return self.next def set_data(self, new_data): self.data = new_data def set_next(self, new_next): self.next = new_next def set_prev(self, new_prev): self.prev = new_prev

image text in transcribed

Using the NodeDLL class, provide an implementation of the Doubly Linked List ADT as discussed in lectures. You will need to implement the following methods: . add before0 . add to heado - add to tail0 . remove) . remove from heado . remove from tailO . IS-empty() - size) .str The implementation of the NodeDLL class is provided to you as part of this exercise. You can simply use: NodeDLL). get_next). get prev), set_next). set prev() as wel as get data() and set data() as necessary in your function definition. It is not necessary to implement this exercise using the "Circular+Dummy Head node" doubly linked list. Nevertheless, you may also try it if you wish. Note: Keep a copy of your solution to this task because you will be extending it step by step in subsequent tasks For example: Test Result d11 list DoublyLinkedList [4, 3, 2, 1, e] for i in range(5): dll list.add to head(i) print (dillist) dll-list DoublyLinkedList() for i in range(5): [0, 1, 2, 3, 4] | dll list.add to tail(i) print (dil list) dll-list = DoublyLinkedLst() | | | [3, 2, 1, ] for i in range(5): dll_list.add to head(i) dll list.removefrom head) print (dll_list) dll-list DoublyLinkedList() for i in range(5): [4, 3, 2, 1] dll list.add to head(i) d11 list.remove from tail() print (dil list) Answer (penalty regime: 0 %) 1 class DoublyLinkedList: def _init__(self): self. head NodeDLL (None) self. head.set_next (self. head) self. head.set_prev(self._head) self-count 4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

8-15 Explain how a cyberattack can be carried out.

Answered: 1 week ago

Question

2. Place a value on the outcomes.

Answered: 1 week ago