Question: Below is the code for a MaxPQ ( max ordered priority queue ) that is implemented private Node first; / / The first node in
Below is the code for a MaxPQ max ordered priority queue that is implemented private Node first; The first node in a list where
the keys appear in decreasing order
public OrderedMaxPQ
first null;
public boolean isEmpty
using a sorted linked list. The items in the linked list appear in sorted order from
greatest to least. However, the insert method has not been implemented. In the
space below the code, write the code for the insert method so that it maintains the
invariant that the items in the list appear in sorted order from greatest to least.
Note, that the key field in each node implements Comparable, so it will have a
compareTo method.
If you cannot answer the question for a generic Key that implements Comparable,
you may answer the question assuming the keys are ints and can be compared using
and for partial credit at most out of points
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
