Question: Hello, I need help for this JAVA homework: Reference Based Linked Lists Linked List Practice A reference-based singly linked list is a basic data structure

Hello, I need help for this JAVA homework:

Reference Based Linked Lists

Linked List Practice

A

reference-based singly linked list is a basic data structure in computer science. Proficiency with linked lists is part of all CS tracks and represents a substantial portion of the Advancement Programming Exam.

This code listing and exercise gives you practice with designing, coding and testing a reference-based linked list.

Tasks in this exercise:

1. Create an ADT interface

2. Create a Node class (nested)

3. Create a LinkedList class

4. Create a ListTester class

1. Create an ADT interface that specifies method signatures for:

* isEmpty method

* size method

* add method that accepts a new item only

* add method that accepts a new item and an index

* remove method that accepts an index

* removeAll method

2. Create a LinkedList class that implements:

* Your ListInterface interface

* All the required methods

* A private method find that accepts an index and returns a node

3. Create a private nested Node class within the LinkedList class with:

* Instance field (type Comparable) item

* Instance field (type Node) next

* Constructor(s)

4. Create a ListTester class to drive your linked list (you may copy and paste the following code):

public class ListTester

{

public static void main(String[] args)

{

LinkedList myList = new LinkedList();

myList.add("Item 1...");

myList.add("Hello there...");

System.out.println(myList);

myList.add(0, "I'm a new item at index 0");

System.out.println(myList);

myList.add(2, "Two! I'm a new item at index 2");

System.out.println(myList);

myList.add(4, "Four, I say! I'm at position 4!");

System.out.println(myList);

//myList.add(-1, "Should error out...");

System.out.println(myList);

System.out.println();

// Remove an item...

myList.remove(3);

System.out.println(myList);

}

}

For lab credit: Run your program and capture the output.

Thank you

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!