Melding Priority Queues

Slides:



Advertisements
Similar presentations
Priority Queues  MakeQueuecreate new empty queue  Insert(Q,k,p)insert key k with priority p  Delete(Q,k)delete key k (given a pointer)  DeleteMin(Q)delete.
Advertisements

Msb(x) in O(1) steps using 5 multiplications Word size n = g∙g, g a power of 2 [M.L. Fredman, D.E. Willard, Surpassing the information-theoretic bound.
Rank-Pairing Heaps Robert Tarjan, Princeton University & HP Labs Joint work with Bernhard Haeupler and Siddhartha Sen, ESA
Union-Find Problem Given a set {1, 2, …, n} of n elements. Initially each element is in a different set. {1}, {2}, …, {n} An intermixed sequence of union.
Lec 6 Feb 17, 2011  Section 2.5 of text (review of heap)  Chapter 3.
Rank-Pairing Heaps Bernhard Haeupler, Siddhartha Sen, and Robert Tarjan, ESA
Initializing A Max Heap input array = [-, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
Course: Data Structures Lecturer: Uri Zwick March 2008
MIKKEL THORUP 1999 Journal of the ACM Undirected Single-Source Shortest Paths with Positive Integer Weights in Linear Time.
Melding Priority Queues Ran Mendelson Robert E. Tarjan Mikkel Thorup Uri Zwick SWAT 2004.
Heaps and heapsort COMP171 Fall 2005 Part 2. Sorting III / Slide 2 Heap: array implementation Is it a good idea to store arbitrary.
Binomial Heaps Jyh-Shing Roger Jang ( 張智星 ) CSIE Dept, National Taiwan University.
Leftist Trees Linked binary tree. Can do everything a heap can do and in the same asymptotic complexity.  insert  remove min (or max)  initialize Can.
Strict Fibonacci Heaps Gerth Stølting Brodal Aarhus University George Lagogiannis Robert Endre Tarjan Agricultural University of Athens Princeton University.
Spring 2015 Lecture 11: Minimum Spanning Trees
Data Structure & Algorithm II.  Delete-min  Building a heap in O(n) time  Heap Sort.
Computer Algorithms Submitted by: Rishi Jethwa Suvarna Angal.
A Worst Case, Constant Time Priority Queue: Beating a Lower Bound Ian Munro University of Waterloo Joint work with Andrej Brodnik (Ljubljana & Luleå) Svante.
Balanced Search Trees Problem: Efficiency of BST is related to tree’s height.  search, insert and remove follow a path from root to desired location 
Data Structure & Algorithm II.  In a multiuser computer system, multiple users submit jobs to run on a single processor.  We assume that the time required.
Λίστα Εργασιών Data Structures for Tree Manipulation D. Harel and R.E. Tarjan. Fast Algorithms for finding nearest common ancestors. SIAM J. Computing,
Change Keys in heaps Fibonacci heap Zhao Xiaobin.
Union & Find Problem 황승원 Fall 2010 CSE, POSTECH 2 2 Union-Find Problem Given a set {1, 2, …, n} of n elements. Initially each element is in a different.
1 Binomial Tree Binomial tree. n Recursive definition: B k-1 B0B0 BkBk B0B0 B1B1 B2B2 B3B3 B4B4.
Four different data structures, each one best in a different setting. Simple Heap Balanced Heap Fibonacci Heap Incremental Heap Our results.
Data Structure II So Pak Yeung Outline Review  Array  Sorted Array  Linked List Binary Search Tree Heap Hash Table.
Review for Exam 2 Topics covered (since exam 1): –Splay Tree –K-D Trees –RB Tree –Priority Queue and Binary Heap –B-Tree For each of these data structures.
MA/CSSE 473 Days Answers to student questions Prim's Algorithm details and data structures Kruskal details.
CSS446 Spring 2014 Nan Wang.  to study trees and binary trees  to understand how binary search trees can implement sets  to learn how red-black trees.
Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at
Initializing A Max Heap input array = [-, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
Exam 3 Review Data structures covered: –Hashing and Extensible hashing –Priority queues and binary heaps –Skip lists –B-Tree –Disjoint sets For each of.
1 Fibonacci heaps: idea List of multiway trees which are all heap-ordered. Definition: A tree is called heap-ordered if the key of each node is greater.
Fibonacci Heaps. Fibonacci Binary insert O(1) O(log(n)) find O(1) N/A union O(1) N/A minimum O(1) O(1) decrease key O(1) O(log(n)) delete O(log(n) O(log(n))
David Kauchak cs062 Spring 2010
Priority Queues An abstract data type (ADT) Similar to a queue
Data Structures Binomial Heaps Fibonacci Heaps Haim Kaplan & Uri Zwick
Topics covered (since exam 1):
Binomial heaps, Fibonacci heaps, and applications
Splay Trees Binary search trees.
Heaps Binomial Heaps Lazy Binomial Heaps 1.
Source: Muangsin / Weiss
Dynamic Dictionaries Primary Operations: Additional operations:
Priority Queues Linked-list Insert Æ Æ head head
Splay Trees Binary search trees.
Priority Queues MakeQueue create new empty queue
Selection in heaps and row-sorted matrices
תרגול 9 Heaps Lempel-Ziv.
Topics covered (since exam 1):
A simpler implementation and analysis of Chazelle’s
Tree Representation Heap.
CS200: Algorithm Analysis
ערמות בינומיות ופיבונצ'י
Heap Sort CSE 2011 Winter January 2019.
Closing a Classical Data Structure Problem Gerth Stølting Brodal
Strict Fibonacci Heaps
Course: Data Structures Lecturer: Uri Zwick March 2008
Binary and Binomial Heaps
Binomial heaps, Fibonacci heaps, and applications
Algorithms: Design and Analysis
Union-Find with Constant Time Deletions
Binomial heaps, Fibonacci heaps, and applications
Priority Queues Supports the following operations. Insert element x.
Topics covered (since exam 1):
Chapter 12 Heap ADT © 2011 Pearson Addison-Wesley. All rights reserved.
CS 6310 Advanced Data Structure Wei-Shian Wang
Fibonacci Heaps & Doubled-Ended Heap Structures
Priority Queues Binary Heaps
A Heap Is Efficiently Represented As An Array
Heaps Section 6.4, Pg. 309 (Section 9.1).
Presentation transcript:

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

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

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}

Meldable Priority Queues Insert Delete Find-Min O(1) O(log n) Dec-Key 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

using our transformation RAM Priority Queues Keys are integers that fit into a single machine word. Standard arithmetical and logical operations take constant time Insert Delete Find-Min O(1) O(log log n) 010010 001001 011010 Dec-Key using our transformation Meld O(1) NO [Thorup ’03]

At most O(log2n) elements! Atomic heaps Insert Delete Find-Min O(1) 011010 000010 010011 At most O(log2n) elements! Meld NO [Fredman-Willard ’94]

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

α(m,n) = min{ k : Ak(m/n) ≥ n } 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

Union Find Represent each set as a rooted tree Union by rank Path compression

Union by rank r+1 r2 r r r1

Path Compression

Non-meldable priority queue + Union Find

Use 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 2 4 5 3 19 2 7 4 8 6 19 2 4 8 6

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

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

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

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