Question: 4. A doubly linked list is based on the following data: public class DoublyLinkedList { private Node head; private class Node{ private T data; private

4. A doubly linked list is based on the following data:

public class DoublyLinkedList{

private Node head;

private class Node{

private T data;

private Node next;

private Node prev;

public Node(T d) {

data = d;

next = null;

prev = null;

}

}

}

(a) Write a member method removeFirstNode() which deletes the first node from a doubly linked list (10 points).

(b) Assume the curNode points to a node in the doubly Linked List. Write a few lines of code to remove this node from the list (10 points).

(c) Write a method getSize(), which returns the number of nodes in the doubly linked list (10 points).

(d) Write a member method find (int position) which returns a Node reference at position in the doubly linked list. Your method should return NULL if the position is out of range (10 points).

(e) Write a method displayBackward(), which displays the doubly linked list in the reversed order. Please note that the doubly linked list does NOT have a tail reference. (10 points)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!