Title: Melding Priority Queues
1Melding Priority Queues
- Ran Mendelson
- Robert E. Tarjan
- Mikkel Thorup
- Uri Zwick
SWAT 2004
2- Improved analysisof transformation
MeldablePriority Queue
Non-meldablePriority Queue
pq(n)a(n) timeper operation
pq(n) timeper operation
or
pq(n)a(n,n/pq(n)) timeper operation
3MeldablePriority Queue
pq(n) timeper operation
pq(N) timeper operation
n number of elements in priority queue Keys are
is 1,2,,N
4Priority Queues
Meldable
O(1) O(log n) O(1) O(1)
10
25
4
7
13
2
17
1
Dec-Key
O(1)
5
38
Meld
Amortized Fredman-Tarjan 87
Worst case Brodal 96
Best possible comparison based results
5RAM Priority Queues
Keys are integers that fit into a single machine
word.Standard arithmetical and logical
operations take constant time
O(1) O(log log n) O(1) O(1)
010010
001001
011010
Dec-Key
using our transformation
Meld
O(1)
NO
Thorup 03
6Atomic heaps
O(1) O(1) O(1)
011010
000010
010011
At most O(log2n) elements!
Meld
NO
Fredman-Willard 94
7Union Find
- makeset
- union
- find
- delete
O(1) O(1) O(a(m,n)) O(1)
a
b
c
d
e
Amortized
Tarjan 75 , Tarjan van Leeuven 84
8Ackermanns function
- A0(j) j1
- Ai(j) Ai-1(j1)(j)
Grows extremely FAST
a(n) min k Ak(1) n a(m,n) min k
Ak(m/n) n
Grows extremelyslow
9Union Find
- Represent each set as a rooted tree
Union by rank
Path compression
10Union by rank
r1
r2
r
r
r1
0
11Path Compression
12Non-meldable priority queueUnion Find
Meldable priority queue
13Use the union-find data stricture to maintain the
sets
Place a non-meldable priority queue at each node
of a union-find tree holding the minimal element
in each one of its subtrees
9
1
5
1
5
2
4
3
7
4
8
6
19
2
19
2
4
8
6
14Handling deletions using path compression
The amortized delete cost is O(pq(n)a(n))
MTZ04
van Emde Boaz, Kaas, Zijlstra 77
15Flavor of improved analysis
rank k
At mostn/2k nodes
size 2k
rank lt k
size lt 2k
Choose k2loglog n.
If fgtn/log n, we are done.
16More flavor of improved analysis
rank k
size 2k
rank lt k
size 2k
rank lt k
size lt 2k
17Conclusion
Sorting
Worst-case non-meldable priority queues
Amortized meldable priority queues