Question: Goal: While using java.util.LinkedList is fine for many applications, developing our own linked list data structure is excellent practice for understanding dynamic data structures. Our

Goal:

While using java.util.LinkedList is fine for many applications, developing our own linked list data structure is excellent practice for understanding dynamic data structures. Our goal for this assignment is to create our own functional Linked List class that we can use in our applications.

Requirements:

1) You are not allowed to use Iterators

2) Your list cannot be doubly linked

Assignment Steps:

Step 1: Create a new Java project named LinkedListProject

Step 2: Create a new Java class in your project named LinkedStringList

Step 3: Add an inner Node class

Step 4: You should include these in your project:

LinkedStringList() (an empty constructor)

addFirst() (adds an element in the first position)

setFirstValue() (sets the value of the element in the first position)

setCurrentValue() (sets the value of the element in the current position)

moveNext() (moves the current reference to the next element)

moveFirst() (moves the current reference to the first position)

isEmpty() (returns whether the list is empty)

getLength() (returns the length of the list)

displayList() (displays all elements in the list)

Step 5: Add the following methods on your own:

add(String value) - add an element in the current position

getCurrentValue() - returns the value of the current element

removeFirst() - remove the first element

remove() - remove the current element

indexOf(String value) - return the position of value, or -1 if not found

sortAscending() - return a new linked list sorted in ascending order using the method suggested in class.

Step 6:

In your main method:

Create an instance of your LinkedStringList class named list.

Call your add() method 3 times to add the values First, Second, and Third to list.

Use moveFirst(), moveNext(), and setCurrentValue() to replace those values with Red, Green, and Blue (respectively).

Use your indexOf() method to display the position of the Green string.

Use displayList() to display the contents of list.

Create a new LinkedStringList instance named mySortedList and use your sortAscending() method to populate that list.

Use displayList() to display the contents of mySortedList.

Call your remove() method twice on mySortedList.

Use displayList() to display the contents of mySortedList (again).

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!