From charlesreid1

m (Replacing charlesreid1.com:3000 with git.charlesreid1.com)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Git Code==
==Git Code==


Link on git.charlesreid1.com: https://charlesreid1.com:3000/cs/java/src/master/priority-queues/UnsortedPQ.java
Link on git.charlesreid1.com: https://git.charlesreid1.com/cs/java/src/master/priority-queues/UnsortedPQ.java
 
==Notes==
 
===Big O Cost===


==Implementation==
==Implementation==
Line 18: Line 14:


Removing the minimum item is an O(N) operation, since the entire array must be traversed to find the minimum element. Note that finding the minimum also requires examining every item in the list.
Removing the minimum item is an O(N) operation, since the entire array must be traversed to find the minimum element. Note that finding the minimum also requires examining every item in the list.


==Flags==
==Flags==

Latest revision as of 03:45, 9 October 2019

Git Code

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

Implementation

Note: you can find a much more detailed walkthrough of a nearly identical class at Priority Queues/Sorted#Implementation.

Insert Method

The unsorted priority queue makes adding very fast - add operations are O(1), because items are just added to the end of the list, in no particular order.

Removing the minimum item is an O(N) operation, since the entire array must be traversed to find the minimum element. Note that finding the minimum also requires examining every item in the list.

Flags