Upload
hubert
View
29
Download
0
Embed Size (px)
DESCRIPTION
Melding Priority Queues. Ran Mendelson Robert E. Tarjan Mikkel Thorup Uri Zwick. SWAT 2004. Improved analysis of transformation. Meldable Priority Queue. Non-meldable Priority Queue. pq(n)+ α (n) time per operation. pq(n) time per operation. or. - PowerPoint PPT Presentation
Citation preview
Melding Priority Queues
Ran MendelsonRobert E. TarjanMikkel Thorup
Uri Zwick
SWAT 2004
2
Non-meldablePriority Queue
MeldablePriority Queue
pq(n) timeper operation
pq(n)+α(n) timeper operation
pq(n)α(n,n/pq(n)) timeper operation
or
Improved analysisof transformation
3
Second transformation
MeldablePriority Queue
pq(n) timeper operation
pq(N) timeper operation
n – number of elements in priority queue
Keys are is {1,2,…,N}
4
Priority Queues
Insert
Delete
Find-Min
10
7
25
13
4
17
38
15Dec-Key
Meld
Meldable
O(1)
O(log n)
O(1)
O(1)
Amortized [Fredman-Tarjan ’87]
Worst case [Brodal ’96]
Best possible comparison based results
2
O(1)
5
RAM Priority Queues
Insert
Delete
Find-Min
Dec-Key
O(1)
O(log log n)
O(1)
O(1)
[Thorup ’03]
Keys are integers that fit into a single machine word.Standard arithmetical and logical operations take constant time
010010
011010
001001
Meld O(1)NO using our transformation
6
Atomic heaps
Insert
Delete
Find-Min
O(1)
O(1)
O(1)
[Fredman-Willard ’94]
011010
010011
000010
Meld NO At most O(log2n)
elements!
7
Union Find
makeset
union
find
delete
a
c
b
d e
O(1)
O(1)
O(α(m,n))
O(1)
[Tarjan ’75 , Tarjan & van Leeuven ’84 ]
Amortized
8
Ackermann’s function
A0(j) = j+1
Ai(j) = Ai-1(j+1)(j)
Grows extremely
FAST
α(n) = min{ k : Ak(1) ≥ n }
α(m,n) = min{ k : Ak(m/n) ≥ n }
Grows extremely
slow
9
Union FindRepresent each set as a rooted tree
Union by rank Path compression
10
Union by rank
0 r1
r2 r r
r+1
11
Path Compression
12
Non-meldable priority queue+
Union Find
Meldable priority queue
13
Place a non-meldable priority queue at each node of a union-find tree
holding the minimal element in each one of its subtrees
3 7
1 5
9
19 2 4 8 6
4 8 619 2
2 4
1 5
Use the union-find data stricture to maintain the sets
14
Handling deletions using path compression
The amortized delete cost is O(pq(n)α(n))
[MTZ’04]
[van Emde Boaz, Kaas, Zijlstra ’77 ]
15
Flavor of improved analysis
rank ≥ k
rank < k
size ≥ 2k
size < 2k
( , )2 2k k
n nf
( , )f n n
At mostn/2k nodes
Choose k=2loglog n. If f>n/log n, we are done.
16
More flavor of improved analysis
rank ≥ ksize ≥ 2k
rank < ksize ≥ 2k
rank < ksize < 2k
17
Conclusion
Sorting
Worst-case non-meldable priority queues
Amortized meldable priority queues