length ()returns the number of items currently in the queue enqueueitempriority )adds the given item to the queue by inserting it in the proper position based on the given priority the priority value must be within the legal range when using bounded priority queue dequeue()removes and returns the front item from the queuewhich is the item with the highest priority the associated priority value is discarded if two items have the same prioritythen those items are removed in fifo order an item cannot be dequeued from an empty queue consider the following code segmentwhich enqueues number of items into priority queue the priority queue is defined with six levels of priority with range of [ the resulting queue is shown in figure bpriorityqueue enqueue"purple" enqueue"black" enqueue"orange" enqueue"white" enqueue"green" enqueue"yellow" ( "white( ( "black"black( ( "green( ( "orange"orange( ( "purple"purple( ( "yellow"yellowfigure abstract view of priority queue resulting from enqueueing several stringsalong with individual priorities the first item to be removed will be the first item with the highest priority notice when items "blackand "greenare enqueued"greenfollows "blackin the queue even though they have the same priority since items with equal priority still obey the fifo principle the following code segment removes the items and prints them to the terminalwhile not isempty(item dequeue(printitem which results in the following outputwhite black green orange purple yellow