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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started