Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a Java program that extends the LinkedList<E> class to ExtLinkedList<E>

ID: 3717353 • Letter: 1

Question

1. Write a Java program that extends the LinkedList<E> class to ExtLinkedList<E> containing the following methods. For time-complexity, assume the size of the list to be n elements. (20 points)

(a) public int countOccurences(E element) that returns the number of occurrences of “element” in the LinkedList if the “element” is found otherwise returns -1. Also, handle the condition when the list is empty. The underlying algorithm of your code should run in O(n) time.

(b) public boolean pairPresence(E element1, E element2) that checks if element1, and element2 are present in the linked list as a consecutive pair and if so returns true, if not, returns false. If there is more than one consecutive pair, you will return the first pair starting from the head of the list. Also, the code should return false when the list is empty or if it has only one element. You can use .equals() method for checking equality of elements. The underlying algorithm of your code should run in O(n) time.

Explanation / Answer

OUTPUT :

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote