I am a couple of java data data structure exercises.
Here is the exercise I am currently doing
Add an array-linked hierarchy to the overall structure. Use the following names:
AbstractNodeArrayMyList
,NodeArraySorted
, andNodeArrayUnsorted
I've already implemented abstract array list, sorted array list, unsorted array list, abstract linked list, sorted linked list, and unsorted linked list.
However I am confused about what this array linked structure or node array is.
I tried doing a google search for an array linked list or structure but all I got was searches that resulted in difference between array and linked list. Can anyone clarify or confirm my initial opinions of what this node array or array linked structure actually is?
When I think of a node, I think of a node in a linked list, something that contains data, and the reference to the node it is connected to, something like from these lecture notes for ListNode.java
public class ListNode {
int data;
ListNode next;
public ListNode() {
this(0, null);
}
public ListNode(int data) {
this(data, null);
}
public ListNode(int data, ListNode next) {
this.data = data;
this.next = next;
}
}
And when I think about array. I think about something that supports random access, like you can access any element in the array and it would take constant time. So would a node array look something like this? (you define the ListNode as a private inner class) and the outside class would look like
public class NodeArray {
private ListNode[] elementData;
...
private class ListNode {
....
}
}
I didn't think my initial idea was right because the whole idea of the generic array list is that it would work with any type of data. Why have a special class for ArrayNode then?