How can a heap be used to implement a priority queue?

What will be an ideal response?

Elements in a heap must be Comparable, which means that they have a compareTo method. The
compareTo method can be written so that the element that has greater priority is ‘greater than’ an element with lower priority.
If the priorities are the same, then the positions in the queue determine the resulting relation between the elements.

Computer Science & Information Technology

You might also like to view...

In a form template, pressing the ________ key moves a user from one field to the next

A) Enter B) Shift C) Tab D) Alt

Computer Science & Information Technology

The calculating machine of Georg and Edvard Sheutz

a. computed the values of polynomial functions. b. typeset the results of its computations. c. performed calculations faster than they could be done manually. d. performed calculations more reliably than they could be done manually. e. All of the above.

Computer Science & Information Technology