This preview shows pages 1–3. Sign up to view the full content.
1
DoubleEnded Priority Queues (DEQUE)
Recall that
PQ supports insert(x,Q) and deletemin(Q) or
deletemax(Q) operations.
Q:
How do we design an ADT that will support both
deletemin(Q) and deletemax(Q) operations?
Minmax Heap
(Atkinson, Sack, Santoro, Strothotte, 1986):
A minmax heap H is an extension of 2heap by fusing a
min heap and a max heap together.
There are two types of nodes in H: min node and max
node. Each node x in H is either a
min node
, x is
≤
all its
descendants, or a
max node,
x is
≥
all its descendants, and
all the nodes in the same level must be of the same type.
A
minlevel (maxlevel)
in H is a collection of all the min
(max) nodes having the same level number.
Dfn.
A minmax heap is a tree satisfying the following
properties:
1.
Structural Property
: H is a complete binary tree.
2.
Relational Property
:
H s
atisfies the minmax heap
property with which, starting at the root at minlevel,
nodes are alternating between minlevel and max
level.
Example:
A minmax heap H.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document2
7
minlevel
75
65
maxlevel
36
48
12
58
minlevel
65
38 56
58 12
62
maxlevel
HW:
Define maxmin heap.
Implementation:
Sequential array implementation with root of H at A[1].
Example:
Array implementation of H.
l
a
s
t
m
a
x
Q
0
1
2
…
7 75 65 36 48 12 58 65 38 56 58 12 62 …
Minmax heap operations:
Twostep process as in binary heap:
1.
Maintain complete binary tree structure after each
insert/delete operation.
2.
This is the end of the preview. Sign up
to
access the rest of the document.
 Winter '07
 Mullins

Click to edit the document details