Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objectives: practice on the following points: - declaring a double linked list - testing the code of the different double linked list operations. - writing

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Objectives: practice on the following points: - declaring a double linked list - testing the code of the different double linked list operations. - writing a suitable main method to construct a double linked list and call the operations - adding some new operations e.g. deleteNodeFirst, deleteNodeLast, insertInOrder The Lab Procedure: 1) The file doubleLinkedList.java must be distributed to the students in the lab to test and practice on the different double linked operations; which was discussed in the lectures and described below. - public void push(int newdata) // This function inserts a new Node at front of the list - public void insertAfter(Node PrevNode, int newdata) // Insert a node after a given node - public void append(int newdata) // Add a new data to the end of the List - void insertBefore(Node NextNode, int newdata) // Insert a node before a given node - void deleteNode( Node del) // delete the node pointed by the parameter del - void printList() //This function prints contents of linked list starting from head 2) The students are required to write a main method containing the declarations to create an object of the class doubleLinkedList and call different functions to test their logics. 3) The students by themselves must write the body of the following methods: - deleteNodeFirst that delete the first occurrence of a given integer from the double linked list. - deleteNodeLast that delete the last occurrence of a given integer from the double linked list. - [for clever students only] insertInOrder that adds an integer in its proper place in a sorted list of integers. Note that: the method deleteNodeFirst can delete all occurrence of the given integer. by removing the return statement from its code The students also must write a proper main method to test the code. The resulting new code the is given in the file doubleLinkedListExcerises.java. doubletinkedListExcerises java Page 1 of 8 doubletinkedistEncerises java Page 2 of 8 doubleLinkedtistExcerises java Page 3 of 8 doubleLinkedListExcenses.java doubleLinkedListExcerises java Page 5 of 8 doubletinkedList Excerises java // test elements of the liet from loft to right looking for an element greater chan q Page 6 of 6 doubleLinkedListExcerises java Page 7 of 8 doubleLinkedtistExcerises.java Page 8 of 8 doublethkod,istjave sobletikedlistiava 29 publie void insertafter (Node PrevNode, int newdata) 31 if (PrevNode == null) //Cheok It the given Node is aull. 33 System, out.println ("The given previous node cannot be nul1"); return; 35 36 Node NewNode = new Node (newdata) ; //A2locate the Node 6 \& 3. Put in the daca 37 NewNode.next = PrevNode.next; //Make next of new Node as next of prev node 38 PrevNode. next = NewNode; //make next of prev node as new node 39 NewHode. prev = PrevNode: 48 Add a new data to the end of the List publia void append (int newdata) 50 52 Node NewNode = new Node (newdata); /, Allocato the Node and score the data in tt 53 Node last = head; 54 Newiode. next = nul1; 55 56 if (head = nuil) (lif the binked itst 25 empty doubleLinkedlist java deubletinkedist jave. doubleLinkedist java doubletinkedist iava Page 6 of 6

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

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions