Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions in class, we discussed the Doubly Linked List Abstract Data Type (section 1.1.4 of your Lecture Notes). A Doubly Linked List contains an extra

image text in transcribed

image text in transcribed

Instructions in class, we discussed the Doubly Linked List Abstract Data Type (section 1.1.4 of your Lecture Notes). A Doubly Linked List contains an extra pointer (known as previous pointer) allowing the traversal of the list in both forward and backward direction. When implementing the LinkedList data structure, we observed the importance of updating the pointers in order to get access to the entire list. Implement the data structure Doubly LinkedList with the following characteristics: DoublyLinkedList0 creates a new doubly linked list that is empty. It needs no parameters and returns nothing. Assume the items in the list are unique addFtrt(item) adds a new Node with value-item at the beginning of the list. It needs the tem and returns nothing. [20 pts] adalLat tem) adds a new Node with value-item at the end of the list It needs the item and returns nothing. [20 pts] addB efore(pmode_value, ttem) adds a new Node with value-item before the Node with value-pnode_value. It needs the value of the reference Node and the item to be added, returns nothing. You can assume the reference node is in the list. [30 pts] addtfter(pnode value, tem) adds a new Node with value-item after the Node with value-pnode_ value. It needs the value of the reference Node and the item to be added returns nothing. You can assume the reference node is in the list. [30 pts) . It needs the value of the reference Node and the item to be added NOTE: There is no partial credit for methods that do not workproperly Code will be tested calling all methods and comparing the Anal list EXAMPLE > dll-DoublyLinkedii3t) >>> dli addFirst (9) >>> dll.addfirst (3) >>> dl1.head >>> dll.addlast (8) >> dll.addlast (12) dll.addLast (56) > dll.printDLL Traveraal Head to Tail 3 4 9 5 e 22 56 Traversal Tail to Head 56 12 8 594 3 > dl1.addBefore (56,4) >> d11.addBefore (9,32) >>> dil addAfter (56,756) >>> d11.addAfter (847 >>> dil.printDLL Traversal Head to Ta11 3 4 329 5 47 12 44 56 756 Traversal Tail Htad 756 S6 44 12 47 5 9 32 3 >>> di1 addLast (999) >> di1 head

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_2

Step: 3

blur-text-image_3

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

What about leadership lessons from particularly good or bad bosses?

Answered: 1 week ago

Question

How would you assess the value of an approach like this?

Answered: 1 week ago

Question

When would you use one approach, and when would you use another?

Answered: 1 week ago