deques deque is double-ended queue you can insert items at either end and delete them from either end the methods might be called insertleft(and insertright()and removeleft(and removeright(if you restrict yourself to insertleft(and removeleft((or their equivalents on the right)the deque acts like stack if you restrict yourself to insertleft(and removeright((or the opposite pair)it acts like queue deque provides more versatile data structure than either stack or queue and is sometimes used in container class libraries to serve both purposes howeverit' not used as often as stacks and queuesso we won' explore it further here priority queues priority queue is more specialized data structure than stack or queue howeverit' useful tool in surprising number of situations like an ordinary queuea priority queue has front and rearand items are removed from the front howeverin priority queueitems are ordered by key value so that the item with the lowest key (or in some implementations the highest keyis always at the front items are inserted in the proper position to maintain the order here' how the mail sorting analogy applies to priority queue every time the postman hands you letteryou insert it into your pile of pending letters according to its priority if it must be answered immediately (the phone company is about to disconnect your modem line)it goes on topwhereas if it can wait for leisurely answer ( letter from your aunt mabel)it goes on the bottom letters with intermediate priorities are placed in the middlethe higher the prioritythe higher their position in the pile the top of the pile of letters corresponds to the front of the priority queue when you have time to answer your mailyou start by taking the letter off the top (the front of the queue)thus ensuring that the most important letters are answered first this situation is shown in figure like stacks and queuespriority queues are often used as programmer' tools we'll see one used in finding something called minimum spanning tree for graphin "weighted graphs alsolike ordinary queuespriority queues are used in various ways in certain computer systems in preemptive multitasking operating systemfor exampleprograms may be placed in priority queue so the highest-priority program is the next one to receive time-slice that allows it to execute