Min-max heaps and generalized priority queues

A simple implementation of double-ended priority queues is presented. The proposed structure, called a min-max heap, can be built in linear time; in contrast to conventional heaps, it allows both</italic> FindMin <italic>and</italic> FindMax <italic>to be performed in constant time;</italic> Insert, DeleteMin, <italic>and</italic> DeleteMax <italic>operations can be performed in logarithmic time. Min-max heaps can be generalized to support other similar order-statistics operations efficiently (e.g., constant time</italic> FindMedian <italic>and logarithmic time</italic> DeleteMedian<italic>); furthermore, the notion of min-max ordering can be extended to other heap-ordered structures, such as leftist trees.