Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

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

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions

Question

Please explain the material used for OPC cement

Answered: 1 week ago

Question

Question What is a secular trust?

Answered: 1 week ago