This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: RESEARCH CONTRIBUTIONS Programming Techniques and Data Structures Min-Max Heaps and Ian Munro Editor Generalized Priority Queues M. D. ATKINSON, J.-R. SACK, N. SANTORO, and T. STROTHOTTE ABSTRACT: ,4 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 FindMin and FindMax to be performed in constant time; Insert, DeleteMin, and DeleteMax 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 FindMedian and logarithmic time DeleteMedian); furthermore, the notion of min-max ordering can be extended to other heap-ordered structures, such as leftist trees. 1. INTRODUCTION A (single-ended) priority queue is a data type sup- porting the following operations on an ordered set of values: 1) find the maximum value (FindMax); 2) delete the maximum value (DeleteMax); 3) add a new value x (Insert(x)). Obviously, the priority queue can be redefined by substituting operations 1) and 2) with FindMin and DeleteMin, respectively. Several structures, some implicitly stored in an array and some using more complex data structures, have been presented for implementing this data type, including max-heaps (or min-heaps) [8, 121. This research was supported in part by the National Science and Engineering Council of Canada under Grants A2419. A2415. and A0332. 01986 ACMOOOl-0782/86/1000-0996 75a: 996 Communications of the ACM Conceptually, a max-heap is a binary tree having the following properties: a) heap-shape: all leaves lie on at most two adja- cent levels, and the leaves on the last level occupy the leftmost positions; all other levels are complete. b) max-ordering: the value stored at a node is greater than or equal to the values stored at its chil- dren. A max-heap of size n can be constructed in linear time and can be stored in an n-element array; hence it is referred to as an implicit data structure [g]. When a max-heap implements a priority queue, FindMax can be performed in constant time, while both DeleteMax and Insert(x) have logarithmic time. We shall consider a more powerful data type, the double-ended priority queue, which allows both FindMin and FindMax, as well as DeleteMin, DeleteMax, and Insert(x) operations. An important application of this data type is in external quicksort [5, p, 1621. A traditional heap does not allow efficient imple- mentation of all the above operations; for example, FindMin requires linear (instead of constant) time in a max-heap. One approach to overcoming this in- trinsic limitation of heaps, is to place a max-heap “back-to-back” with a min-heap as suggested by Wil- liams [8, p. 6191. This leads to constant time Find either extremum and logarithmic time to Insert an element or Delete one of the extrema, but is some- what trickier to implement than the method follow- ing....
View Full Document
- Winter '07
- Data Structures