Question: answer the following in Java The following gives a partial implementation of a class named MyList in C++ and Java. A MyList object is a

answer the following in Java

answer the following in Java The following gives a partial implementation of

The following gives a partial implementation of a class named MyList in C++ and Java. A MyList object is a singly-linked list, where the first node is referenced by the variable head, and the last node is referenced by the variable tail. // Java class ListNode t public ListNode (E data, ListNode next)f this.data = data; this.next = next; public E data; public ListNode next; class MyList head, tail; template class ListNode f public: E data; ListNode next; istNode *ptr NULL): data(item), next (ptr) {} = template class MyList f private: ListNode *head, *tail; b; Implement the following methods (in C++ or Java) in the class MyList: 1. indexOf (elm): This method returns the index of the first occurrence of elm in this list. It returns -1 if elm does not occur in the list. 2. hashCode(): Returns the hash code of this list. Let the size be n, and hashCode (e) be the hash code of the ith element (i 0, 1, ., n-1). Then the hash code of this list is ?7(i + 1) x hashCode (ei). It is assumed that the element type E provides a method called hashCode

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!