) IN JAVA: Write a recursive method lowestPaidEmployeeRec that is placed in the linked list after the method countHighEarners. Method returns employee with lowest salary in entire linked lists of employees. Assume the same LinkedList class as is given as in question 10 above.
// PRECONDITION: Linked list is not empty.
public Employee lowestPaidEmployeeRec(Node first) // first is reference to the beginning of linked list. { } |
ALGO:-
public Employee lowest(Node first)
{
Node next = first.next;
if(next == 0)
return first.value;
int fromNext= lowest(next);
return fromNext < first.value ? fromNext : node.value;
}
public Employee lowestPaidEmployeeRec(Node first) // first is reference to the beginning of linked list.
{
return lowest(first);
}
Get Answers For Free
Most questions answered within 1 hours.