Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part C, A1C (10 marks) Write a Python program, with the given Python files. Doubly-Linked List (DLL): Implement a Doubly-Linked List o Students have learnt

image text in transcribedimage text in transcribedimage text in transcribed

Part C, A1C (10 marks) Write a Python program, with the given Python files. Doubly-Linked List (DLL): Implement a Doubly-Linked List o Students have learnt conventional (Singly-) Linked-List in our course. In this part, students should implement a simple-version of Doubly-Linked List: Each node in this Doubly-Linked List has two links: one for the next node as in singly- linked list, the other for the previous node. The head node has no previous link and the tail node has no next link. Some operations could be done for efficiently with this Doubly-Linked List, which require tracing backward (the previous node of the current node). Students should reuse and modify the given codes of (Singly-) Linked-List in our course. head tail 11 77 File Aonec.py, to be modified and completed by student. o Include a given class of nodes with a value and two links to previous and next nodes): # Aonec.py, for IDSA Assign 1 class DLNode: # modelling a node with doubly-linked def __init__(self, invalue=None, inPrev=None, inNext=None): # constructor self.value = invalue # the node data value, default None self.prevN = inPrev # the previous node, default None self.nextN = inNext # the next node, default None class DLList: # defining a class of Doubly-Linked List def __init_(self): # constructor self.headN = None # the head Node self.tailN = None # the tail Node # MORE TO BE MODIFIED AND FINISHED Extra Operations (methods of the class) to be implemented by Students: At least one line of simple comment for each extra operation required Operation (DLList) Description _init_(): Create and initiate a new DLL (constructor, GIVEN) insertAsTail(elt): Insert element elt as a new tail (GIVEN) displayDL(): Traverse & display node values, in forward order (GIVEN) insertBefore(refelt, elt): Insert element elt, before a reference refElt Do not insert if refelt not existing insertAfter (refelt, elt): Insert element elt, after a reference refelt Do not insert if refElt not existing displayDLBackw(): Traverse & display node values, in backward order o o Given Materials: o Python file AoneC.py, to be modified and completed by student. Also modify top comments for your STUDENT INFO. (DO NOT modify this given portions, including given methods if any) o Python file AoneCT.py for basic running and testing. I DO NOT modify this given test file, except the STUDENT INFO part. Sample console display output of executing the main testing program Aonect.py === A1C, DLList program, by === 1. New DLL created --- >>> DOUBLY-Linked-List Display: > ... AN EMPTY LIST 2. Insert some items >>> DOUBLY-Linked-List Display: > ... head , tail 11 > 22 > 33 > 55 > 77 > 99 --- 3. insertAfter(55,66) >>> DOUBLY-Linked-List Display: > head , tail : > 11 > 22 > 33 > 55 > 66 > 77 > 99 4. insertBefore(55,44) >>> DOUBLY-Linked-List Display: > head , tail : > 11 > 22 > 33 > 44 > 55 > 66 > 77 > 99 --- 5. insertAfter(77,88) >>> DOUBLY-Linked-List Display: > head , tail : > 11 > 22 > 33 > 44 > 55 > 66 > 77 > 88 > 99 >>> DOUBLY-Linked-List Display, Backwards: > FROM ... tail , head === 1. New DLL created --- >>> DOUBLY-Linked-List Display: > ... AN EMPTY LIST 2. Insert some items >>> DOUBLY-Linked-List Display: > ... head , tail 11 > 22 > 33 > 55 > 77 > 99 --- 3. insertAfter(55,66) >>> DOUBLY-Linked-List Display: > head , tail : > 11 > 22 > 33 > 55 > 66 > 77 > 99 4. insertBefore(55,44) >>> DOUBLY-Linked-List Display: > head , tail : > 11 > 22 > 33 > 44 > 55 > 66 > 77 > 99 --- 5. insertAfter(77,88) >>> DOUBLY-Linked-List Display: > head , tail : > 11 > 22 > 33 > 44 > 55 > 66 > 77 > 88 > 99 >>> DOUBLY-Linked-List Display, Backwards: > FROM ... tail , 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

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions