Implement the method int count(E fromElement, E toElement) for the class SinglyL
ID: 3705918 • Letter: I
Question
Implement the method int count(E fromElement, E toElement) for the class SinglyLinkedList presented in class. The method returns the number of elements in the list between the first instance of fromElement and the first instance of toElement in the list, including fromElement and toElement. We have the following constraints and specifications for our methods: • The implementation of count must be recursive. No mark will be given for an iterative implementation. • If fromElement cannot be found in the list, the method returns 0. • If toElement cannot be found in the list after fromElement, the method returns the number of elements in the list between the first instance of fromElement and the end of the list, fromElement included. • The method should be efficient and not visit nodes it doesn’t need to visit.
Explanation / Answer
Hi Dear,
Please find my implementation.
Please DONT forgot to rate my answer. We are working hard for you Guys!!