dequeued first the bounded priority queuein which the number of priorities is fixedallows for an efficient implementation with the use of an array of queues (section the unbounded priority queue does not place any restriction on the maximum positive integer value that can be used as the priority values with an unlimited number of prioritiesthe array of queues implementation would not be very efficient and could waste lot of space insteadwe would have to use either the python list (section or linked list (section based implementation of the priority queue min-heap can also be used to implement the general priority queue the ordering of the heap nodes is based on the priority associated with each item in the queue for examplefigure illustrates the contents of the heap for the example priority queue from figure since lower values indicate higher prioritythe item with the highest priority will always be in the root of the minheap when that item is dequeuedthe item with the next highest priority will work its way to the top as the sift-down operation is performed "white "black "purple "orange "green "yellowfigure contents of the heap used in the implementation of priority queue when using heap implemented as an arraythe operations of the general priority queue are very efficientboth the enqueue and dequeue operations have worst case times of (log nan array-based version of the heap is sufficient in applications where the maximum capacity of the queue is known beforehand if the heap is implemented using python listthe enqueue and dequeue operations have worst case times of (nsince the underlying array may have to expand or shrinkbut amortized cost of (log ntable compares the worst case times and amortized cost for various implementations of the unbounded priority queue worst case amortized implementation enqueue dequeue enqueue dequeue python list linked list heap (arrayheap (listo(no( (log no(no(no(no(log no(no( (log no(no(log ntable time-complexities for various implementations of the bounded priority queue