Question: Write a Java program to simulate ( represent ) a linked list structure using arrays. You will need the following data structures: One Array (
"Write a Java program to simulate represent a linked list structure using arrays. You will need the following data structures:
One Array name it linkedList that will contain the data in the linked list eg character values: A B C etc...
Another integer array name it forwarder that will serve as a corresponding set of forward ers.
A single external field integer named front that will to the front of the linked list the first element in the list
A single external field integer named rear that will to the rear of the linked list the last element in the list
For example,
linkedList:
data array A B D E F G C Note that the letter C is intentionally left out Array size is bigger than content.
er array after inserting C a XK fter B
public static void insertElement char y char x insert method header
public static void insertElement char yremove element method header h
So linkedList A linkedList F etc...
A variable named front will contain the value the index of the first element
rear will contain the value the index of the last element, G
forwarder: indicates a er beyond the end of linkedList, or null.
ie forwarder will initially have the value which s to linkedList or the value E You can read this as: the element in linkedList indexed by s to the element in linkedList indexed by Note that the value in forwarder is then itself used as an index in the array linkeList to to the next element in the list.
Within your program, provide methods that will perform the following functions:
insertElementafterElement newElement that will insert an element anywhere within the middle of the linked list not before the front or after the rear
removeElementelementValue that will remove delete an element from the middle of the list not the front or the rear
For example, if you wanted to insert the element C after B in the array linkedList, you would simply add an element of value C to the end of the linkedList array, and then manipulate the forwarder array accordingly. After the insert operation, the two arrays should result in the following configuration:
linkedList: A B D E F G C
forwarder:
Note that the array elements themselves are not moved from their original positions in the array. The inserted element C is simply added at the end of the array position and then the forwarder array is updated accordingly: linkedList element B is now ing to element linkedList instead of linkedList Note also that the newly inserted element C now s to position in the linkedList array.
It is left as an exercise for the student to determine the steps involved in a removeElementelementValue operation.
Please don't copypaste from previous chegg answers, Im looking for original work, thanks
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
