Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Doubly linked lists are similar to ordinary linked lists. The major difference is that nodes have three instead of two fields. The first field is
Doubly linked lists are similar to ordinary linked lists. The major difference is that nodes have three instead of two fields. The first field is the data field, the second field is the previous node field (which points to the previous node in the list) and the third node is the next node field (which points to the next node in the list). For example, a doubly linked list might look like: head 1 22 3 tail null null Write a class DNode which implements nodes of a doubly linked lists as described above, including constructor and methods for getting and setting data and references fields. Write a class DLinkedlist which uses class DNode. Class DLinkedlist has three private data members head, tail and size as in the case of ordinary linked lists. Methods include: Constructor which sets head and tail references to null and size to zero public void insert(int n) which inserts integer n at the end of the list public void remove() which removes the last entry in the list public void remove(int n) which removes the specified integer if it is in the list, otherwise it reports that such an entry does not exist public String toString() which returns the string representation of the list public String reverse() which returns the string representation of the reversed list
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