Question: Question 2 ( 7 0 % ) : Create a class DoublyLinkedList to implement a doubly linked list and implement the following functions: 1 .
Question :
Create a class DoublyLinkedList to implement a doubly linked list and implement the following functions:
printList: This function prints all elements in the linked list.
addFirstE e: This function adds a new node with element e at the front of a linked list.
addLastE e: This function adds a new node with element e at the end of a linked list.
deleteFirst: This function deletes a node at the front of a linked list. The function returns the deleted nodes element.
deleteLast: This function deletes a node at the end of a linked list. The function returns the deleted nodes element.
Create two lists in the main function with the following data:
List :
List should be created using addFirstE e and then the items in the list should be printed. For this list, show the operation of deleteFirst to delete the first element and print the list again.
List: AppleBananaCherryGrapeOrange
List should be created using addLastE e and then the items in the list should be printed. For this list, show the operation of deleteLast to delete the last element and print the list again.
Insert your Java code in the box below. Also, submit the java code.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
