Question

) 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. { } |

Answer #1

**ALGO:-**

- Recursively Call for the function till we are not getting the last node once we reached the last node then return the value.
- while the value is returned we will compare it with the previous value and so on.
- At the end we will return the lowest value from the linked list.

```
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);
}
```

public class LinkedList
{
private Node
list;
public
LinkedList()
{
list = null;
}
public Node
getList()
{
return list;
}
. . .//other
methods
// insert
method printHighEarners here
// insert
method lowestPaidEmployeeRec
private class
Node
{
public Employee data;
public Node next;
public Node(Employee emp)
{
data = emp;
next = null;
}
public String toString()...

IN JAVA: Write recursive method to return true if a given array
has element equal to employee emp, or returns false otherwise.
Array can be empty or not.
//PRECONDITION: Varible n denotes the number of occupied
positions in the array and must be non-negative.
Employee class has method getSalary() that returns employee's
salary,
// and it has method boolean equals(Employee emp) that accept an
employee object and returns true if employee calling the equals
method is equal as employee emp,...

Write recursive method to return true if a given array of
integers, named numbers, with n occupied positions is sorted in
ascending (increasing) order, or returns false otherwise. Array can
be empty or not.
//PRECONDITION: Varible n denotes the number of occupied
positions in the array and must be non-negative.
Employee class has method getSalary() that returns employee's
salary.
// An empty array and an array with single element in it, are
sorted. Method isSortedRec must be recursive and
returns...

Write recursive method to return true if a given array has
element equal to employee emp, or returns false otherwise. Array
can be empty or not.
//PRECONDITION: Varible n denotes the number of occupied
positions in the array and must be non-negative.
Employee class has method getSalary() that returns employee's
salary,
// and it has method boolean equals(Employee emp) that accept an
employee object and returns true if employee calling the equals
method is equal as employee emp, and returns...

1. Design and implement a CircularLinkedList, which is
essentially a linked list in which the next reference of the tail
node is set to refer back to the head of the list (rather than
null) . Start from the SinglyLinkedList provided in the Lecture
(not the built-in Java LinkedList class).
2. Starting from SinglyLinkedList
you will need to modify or complete methods: first(), last(),
addFirst(), addLast(), removeFirst(), toString(), and also create a
new rotate() method which will move the tail to...

Write in Java (Not Javascript)
Provide an implementation of priority queue using double-ended
doubly linked lists. Recall that double-ended means keeping first
and last references and doubly linked feature allows us to go
backwards, using a prev reference at each Link. Also, note that the
greater the number, the lower the priority. For instance, 2 is of
higher priority compared to 5.
Specifically, write a class LinkedListPriorityQ
which implements the priority queue methods:
boolean isEmpty()
void enqueue(int item)
int dequeue()...

Write a C++ recursive function that counts the number of nodes
in a singly linked list.
(a) Test your function using different singly linked lists.
Include your code.
(b) Write a recurrence relation that represents your
algorithm.
(c) Solve the recurrence relation using the iterating or
recursive tree method to obtain the running time of the algorithm
in Big-O notation.

Given this definition of a generic Linked List node:
public class LLNode { private T data;
private LLNode next; public
LLNode(T data, LLNode next) {
this.data =
data;
this.next = next; } public
void setNext(LLNode newNext){ next = newNext; }
public LLNode getNext(){ return next; } public T
getData() {return data;} }
Write the findMinimumNode method body. This method returns the
linked list node that contains the minimum value in the...

Java Language
Add a method (convertToRing ()) that converts the list to a circular. This is,
which makes the last node instead of pointing to null point to the first.
Code:
class Node {
int value;
Node nextNode;
Node(int v, Node n)
{
value = v;
nextNode = n;
}
Node (int v)
{
this(v,null);
}
}
class LinkedList
{
Node head; //head = null;
LinkedList()
{
}
int length()
{
Node tempPtr;
int result = 0;
tempPtr = head;...

Java Language
Add a method (convertToRing ()) that converts the list to a circular. This is,
which makes the last node instead of pointing to null point to the first.
Code:
class Node {
int value;
Node nextNode;
Node(int v, Node n)
{
value = v;
nextNode = n;
}
Node (int v)
{
this(v,null);
}
}
class LinkedList
{
Node head; //head = null;
LinkedList()
{
}
int length()
{
Node tempPtr;
int result = 0;
tempPtr = head;...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 3 minutes ago

asked 20 minutes ago

asked 22 minutes ago

asked 31 minutes ago

asked 32 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 2 hours ago