Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Assignment1: Implementing a doubly Linked list Please follow the directives and don't make it too complicated: The doubly linked list allows backward as well

Java Assignment1: Implementing a doubly Linked list

Please follow the directives and don't make it too complicated:

The doubly linked list allows backward as well as forward traverse through the list. Each node has two references to other nodes instead of one. The first is to the next node, as in ordinary lists. The second is to the previous node as depicted by the figure below.

image text in transcribed

What to Do?

Implement the MyDLinkedList class as depicted by the figure below.

image text in transcribed

image text in transcribed

Programming language: JAVA

  1. The class should implement the MyList interface (all abstract methods defined in MyList should be implemented in MyDLinkedList) and should contain three constructors to create an empty list, create a list from an array of objects or create a list from a List (the list could be an ArrayList or a LinkedList).
  1. Define and implement all methods in MyDLinkedList. The addAll and removeAll methods are described below:
 boolean addAll(List otherList) 
Appends all of the elements in the otherList to the end of this list. The method returns true if this list changed as a result of the call.
 boolean addAll(int index, List otherList)
 

Inserts all of the elements in the specified list into this list at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The method returns true if this list changed as a result of the call.

Parameters: index - index at which to insert the first element from the specified collection

otherList - list containing elements to be added to this list

 boolean removeAll(E target, int index1, int index2)

removes all elements from the list that are equal to target that are held in between index1 and index2. The removeAll method is not well specified. Carefully define your detailed vision for removeAll including preconditions and exceptions that will be thrown.

  • Write a test program that creates Three MyDLinkedList instances, list1, list2 and list3 and show that the three constructors and all methods implemented in MyDLinkedList class are working properly.

To Submit:

1. All classes and interface code in one file.

2. The code must be commented.

Thanks!

head next prev next next next - Null tail prev prev Null+ prev MyList Interface interface MyList

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_2

Step: 3

blur-text-image_3

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 Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

Determine miller indices of plane A Z a/2 X a/2 a/2 Y

Answered: 1 week ago