From charlesreid1

Revision as of 03:22, 22 June 2017 by Admin (talk | contribs) (Created page with "Link on git.charlesreid1.com: https://charlesreid1.com:3000/cs/java/src/master/priority-queues/SortedPriorityQueue.java Sorted priority queue class implements a sorted list t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Link on git.charlesreid1.com: https://charlesreid1.com:3000/cs/java/src/master/priority-queues/SortedPriorityQueue.java

Sorted priority queue class implements a sorted list to keep track of items in the priority queue.

This class implements insertion sort for each add operation to keep the minimum at the front of the list.

This means add() is O(N).

The removal of the minimum item is then very easy - it is removed from the front of the list. Removal (and peek) is an O(1) operation.