Question: Optional > findRefBefore ( T elem ) If the list contains elem, then this function should return a reference to that list node. If the

Optional> findRefBefore(T elem)
If the list contains elem, then this function should return a reference to that list node.
If the list does not contain elem, then this function should return a reference to the node that
would immediately come before a node with value elem if it were to be inserted into the list.
If elem is smaller than every element in the list (ie the elem would be inserted at the head of the
list) then this function should return Optional.empty().
For a list of length n, this function should run in O(n).

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 Programming Questions!