queues the implementation of the priority queue using an array of queues is also quite simple but can we obtain constant time operationswe begin with the isempty(and len operations since data field is maintained to store the number of items in the priority queueboth can be performed in constant time the enqueue operation also requires constant time since adding an item to general queue can be done in constant time as can accessing an individual queue in the array dequeueing from general queue implemented as linked list can be done in constant time but since we must iterate through the array to find the first non-empty queuethe priority dequeue operation requires (ptime while this time is linearit is linear with respect to the number of priorities and not to the number of elements in the queue (nwhen the number of priorities is quite smalllisting the bpriorityq py module implementation of the bounded priority queue adt using an array of queues in which the queues are implemented using linked list from array import array from llistqueue import queue class bpriorityqueue creates an empty bounded priority queue def __init__selfnumlevels )self _qsize self _qlevels arraynumlevels for in rangenumlevels self _qlevels[iqueue(returns true if the queue is empty def isemptyself )return lenself = returns the number of items in the queue def __len__self )return lenself _qsize adds the given item to the queue def enqueueselfitempriority )assert priority > and priority len(self _qlevels)"invalid priority level self _qlevels[priorityenqueueitem removes and returns the next item in the queue def dequeueself make sure the queue is not empty assert not self isempty()"cannot dequeue from an empty queue find the first non-empty queue len(self _qlevelswhile and not self _qlevels[iisempty( + we know the queue is not emptyso dequeue from the ith queue return self _qlevels[idequeue(