Presentation is loading. Please wait.

Presentation is loading. Please wait.

Melding Priority Queues Ran Mendelson Robert E. Tarjan Mikkel Thorup Uri Zwick SWAT 2004.

Similar presentations


Presentation on theme: "Melding Priority Queues Ran Mendelson Robert E. Tarjan Mikkel Thorup Uri Zwick SWAT 2004."— Presentation transcript:

1 Melding Priority Queues Ran Mendelson Robert E. Tarjan Mikkel Thorup Uri Zwick SWAT 2004

2 2 Non-meldable Priority Queue Meldable Priority Queue pq(n) time per operation pq(n)+α(n) time per operation pq(n)α(n,n/pq(n)) time per operation or Improved analysis of transformation

3 3 Second transformation Meldable Priority Queue pq(n) time per operation pq(N) time per operation n – number of elements in priority queue Keys are is {1,2,…,N}

4 4 Priority Queues Insert Delete Find-Min 10 7 25 13 4 17 38 1 5 Dec-Key Meld Meldable O(1) O(log n) O(1) Amortized [Fredman-Tarjan ’87] Worst case [Brodal ’96] Best possible comparison based results 2 O(1)

5 5 RAM Priority Queues Insert Delete Find-Min Dec-Key O(1) O(log log n) 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 MeldO(1)NO using our transformation

6 6 Atomic heaps Insert Delete Find-Min O(1) [Fredman-Willard ’94] 011010 010011 000010 MeldNO At most O(log 2 n) elements!

7 7 Union Find makeset union find delete a c b de O(1) O(α(m,n)) O(1) [Tarjan ’75, Tarjan & van Leeuven ’84 ] Amortized

8 8 Ackermann’s function A 0 (j) = j+1 A i (j) = A i-1 (j+1) (j) Grows extremely FAST α(n) = min{ k : A k (1) ≥ n } α(m,n) = min{ k : A k (m/n) ≥ n } Grows extremely slow

9 9 Union Find Represent each set as a rooted tree Union by rankPath compression

10 10 Union by rank 0 r1r1 r2r2 r r r+1

11 11 Path Compression

12 12 Non-meldable priority queue + Union Find Meldable priority queue

13 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 37 15 9 192486 486 2 24 15 Use the union-find data stricture to maintain the sets

14 14 Handling deletions using path compression The amortized delete cost is O(pq(n)α(n)) [MTZ’04] [van Emde Boaz, Kaas, Zijlstra ’77 ]

15 15 Flavor of improved analysis rank ≥ k rank < k size ≥ 2 k size < 2 k At most n/2 k nodes Choose k=2loglog n.If f>n/log n, we are done.

16 16 More flavor of improved analysis rank ≥ k size ≥ 2 k rank < k size ≥ 2 k rank < k size < 2 k

17 17 Conclusion Sorting Worst-case non-meldable priority queues Amortized meldable priority queues


Download ppt "Melding Priority Queues Ran Mendelson Robert E. Tarjan Mikkel Thorup Uri Zwick SWAT 2004."

Similar presentations


Ads by Google