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
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