Question: This is a partial implementation of class TheList in Java. TheList object is a singly-linked list. Where the first node is referenced by the var
This is a partial implementation of class TheList in Java. TheList object is a singly-linked list. Where the first node is referenced by the var head, and the last node is referenced by the var tail.
-------------------------------------------------------------
class ListNode
public ListNode(E data, ListNode
this.data = data;
this.next = next;
}
public E data;
public ListNode
}
class TheList
...
private ListNode
}
-------------------------------------------------------------
Implement this function in Java in the class TheList:
hashCode(): this function returns the hash code of the list. Let size be n, and hashCode(ei) be the hash code of the ith element (i = 0, 1, ... , n-1).
Then the hash code of this list is ?ni ( i +1) X hashCode(ei). It is assumed that the element type E provides a function called hashCode.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
