Rank-Pairing Heaps Bernhard Haeupler, Siddhartha Sen, and Robert Tarjan, ESA 2009 1.

Slides:



Advertisements
Similar presentations
Fibonacci Heaps Especially desirable when the number of calls to Extract-Min & Delete is small (note that all other operations run in O(1) This arises.
Advertisements

COL 106 Shweta Agrawal and Amit Kumar
Heaps1 Part-D2 Heaps Heaps2 Recall Priority Queue ADT (§ 7.1.3) A priority queue stores a collection of entries Each entry is a pair (key, value)
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.
Advanced Data structure
Rank-Pairing Heaps Robert Tarjan, Princeton University & HP Labs Joint work with Bernhard Haeupler and Siddhartha Sen, ESA
Pairing Heaps. Experimental results suggest that pairing heaps are actually faster than Fibonacci heaps.  Simpler to implement.  Smaller runtime overheads.
Binary Heaps CSE 373 Data Structures Lecture 11. 2/5/03Binary Heaps - Lecture 112 Readings Reading ›Sections
Rank-Balanced Trees Siddhartha Sen, Princeton University WADS 2009 Joint work with Bernhard Haeupler and Robert E. Tarjan 1.
Nick Harvey & Kevin Zatloukal
Binomial Heaps. Min Binomial Heap Collection of min trees
Initializing A Max Heap input array = [-, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
Instructors: C. Y. Tang and J. S. Roger Jang All the material are integrated from the textbook "Fundamentals of Data Structures in C" and some supplement.
Fibonacci Heaps. Single Source All Destinations Shortest Paths
Priority Queues1 Part-D1 Priority Queues. Priority Queues2 Priority Queue ADT (§ 7.1.3) A priority queue stores a collection of entries Each entry is.
0 Course Outline n Introduction and Algorithm Analysis (Ch. 2) n Hash Tables: dictionary data structure (Ch. 5) n Heaps: priority queue data structures.
5.9 Heaps of optimal complexity
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.
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Fibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 11 Tuesday, 12/4/01 Advanced Data Structures Chapters.
Priority Queues, Heaps & Leftist Trees
Binary Trees Chapter 6.
1 Binomial heaps, Fibonacci heaps, and applications.
New Balanced Search Trees Siddhartha Sen Princeton University Joint work with Bernhard Haeupler and Robert E. Tarjan.
Strict Fibonacci Heaps Gerth Stølting Brodal Aarhus University George Lagogiannis Robert Endre Tarjan Agricultural University of Athens Princeton University.
§8 Binomial Queues Haven’t we had enough about queues? What is a binomial queue for? Well, what is the average time for insertions with leftist or skew.
Chapter 21 Binary Heap.
Chapter 21 Priority Queue: Binary Heap Saurav Karmakar.
PRIORITY QUEUES AND HEAPS CS16: Introduction to Data Structures & Algorithms Tuesday, February 24,
1 Heaps (Priority Queues) You are given a set of items A[1..N] We want to find only the smallest or largest (highest priority) item quickly. Examples:
Chapter 2: Basic Data Structures. Spring 2003CS 3152 Basic Data Structures Stacks Queues Vectors, Linked Lists Trees (Including Balanced Trees) Priority.
1 Joe Meehean.  We wanted a data structure that gave us... the smallest item then the next smallest then the next and so on…  This ADT is called a priority.
Change Keys in heaps Fibonacci heap Zhao Xiaobin.
Four different data structures, each one best in a different setting. Simple Heap Balanced Heap Fibonacci Heap Incremental Heap Our results.
Priority Queues Two kinds of priority queues: Min priority queue. Max priority queue. Nov 4,
Gerth stølting Brodal 1 Closing a Classical Data Structure Problem Gerth Stølting Brodal : Strict Fibonacci Heaps joint work with George Lagogiannis Robert.
1 Fat heaps (K & Tarjan 96). 2 Goal Want to achieve the performance of Fibonnaci heaps but on the worst case. Why ? Theoretical curiosity and some applications.
Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at
CMSC 341 Binomial Queues and Fibonacci Heaps. Basic Heap Operations OpBinary Heap Leftist Heap Binomial Queue Fibonacci Heap insertO(lgN) deleteMinO(lgN)
Lecture 9COMPSCI.220.FS.T Lower Bound for Sorting Complexity Each algorithm that sorts by comparing only pairs of elements must use at least 
Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.
Heaps © 2010 Goodrich, Tamassia. Heaps2 Priority Queue ADT  A priority queue (PQ) stores a collection of entries  Typically, an entry is a.
Fibonacci Heaps. Analysis FibonacciAnalysis.ppt Video  iew/cop5536sahni
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 Heap Fibonacci heapshave better asymptotic time bounds than binary heaps for the INSERT, UNION, and DECREASE-KEY operations, and they.
Heaps, Heap Sort, and Priority Queues. Background: Binary Trees * Has a root at the topmost level * Each node has zero, one or two children * A node that.
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))
Leftist Trees Linked binary tree.
Data Structures Binomial Heaps Fibonacci Heaps Haim Kaplan & Uri Zwick
Binomial heaps, Fibonacci heaps, and applications
Binomial Heaps On the surface it looks like Binomial Heaps are great if you have no remove mins. But, in this case you need only keep track of the current.
Heaps © 2010 Goodrich, Tamassia Heaps Heaps
Priority Queues MakeQueue create new empty queue
Fibonacci Heaps Remove arbitrary is useful in (for example) correspondence structures and may also be used to do an increase key in a min structure (remove.
Pairing Heaps Actual Complexity.
A simpler implementation and analysis of Chazelle’s
ערמות בינומיות ופיבונצ'י
Closing a Classical Data Structure Problem Gerth Stølting Brodal
Strict Fibonacci Heaps
Binary and Binomial Heaps
Topic 5: Heap data structure heap sort Priority queue
Binomial heaps, Fibonacci heaps, and applications
Union-Find with Constant Time Deletions
Fibonacci Heaps.
Binomial heaps, Fibonacci heaps, and applications
Priority Queues Supports the following operations. Insert element x.
Fibonacci Heaps & Doubled-Ended Heap Structures
Pairing Heaps Actual Complexity
CS210- Lecture 13 June 28, 2005 Agenda Heaps Complete Binary Tree
Presentation transcript:

Rank-Pairing Heaps Bernhard Haeupler, Siddhartha Sen, and Robert Tarjan, ESA

Observation Computer science is (still) a young field. We often settle for the first (good) solution. It may not be the best: the design space is rich. 2

3 Research Agenda For fundamental problems, systematically explore the design space to find the best solutions, seeking elegance: “ a quality of neatness and ingenious simplicity in the solution of a problem (especially in science or mathematics).”  wordnet.princeton.edu/perl/webwn Keep the design simple, allow complexity in the analysis.

Heap (Priority Queue) Problem Maintain a set (heap) of items, each with a real-valued key, under the operations Find minimum: find the item of minimum key in a heap Insert: add a new item to a heap Delete minimum : remove the item of minimum key Meld: Combine two item-disjoint heaps into one Decrease key: subtract a given positive amount from the key of a given item in a known heap Goal: O(log n) for delete min, O(1) for others

Related Work Fibonacci heaps achieve the desired bounds (Fredman & Tarjan, 1984); so do Peterson’s heaps (1987) Høyer’s heaps (1995) Brodal’s heaps (1996), worst-case Thin heaps (Kaplan & Tarjan, 2008) Violation heaps (Elmasry, 2008) Quake heaps (Chan, 2009) Not pairing heaps:  (loglog n) time per key decrease, but good in practice

Heap-ordered model Half-ordered model

Half-ordered model

Half-ordered model

Half-ordered tree: binary tree, one item per node, each item less than all items in left subtree Half tree: half-ordered binary tree with no right subtree Link two half trees: O(1) time, preserves half order 5 10 AB A 5 B +

Heap: a set (circular singly-linked list) of half trees, with minimum root first on list; access via last on list Find min: return minimum Insert: Form a new one-node tree, combine with current set of half trees, update the minimum Meld: Combine sets of half trees, update the minimum Delete min: Remove minimum root (forming new half trees); Repeatedly link half trees, form a set of the remaining trees

How to link? Use ranks: leaves have rank zero, only link trees whose roots have equal rank, increase winner’s rank by one: All rank differences are 1: a half tree of rank k is a perfect binary tree plus a root: 2 k nodes, rank = lg n + k k - 1 k k k + 1 Vuillemin’s binomial queues!

Delete minimum Delete min Each node on right path becomes a new root

Link half trees of equal rank Array of buckets, at most one per rank Delete min

Link half trees of equal rank Array of buckets, at most one per rank Form new set of half trees “multipass”

Delete min Form new set of half treesFind new minimum in O(log n) time

Keep track of minimum during links Find minimum in O(log n) additional time Delete min: lazier linking “one-pass”

Form new set of half trees Delete min: lazier linking

Amortized Analysis of Lazy Binomial Queues  = #trees Link: O(1) time,  = -1, amortized time = 0 Insert: O(1) time,  = 1 Meld: O(1) time,  = 0 Delete min: if k trees after root removal, time is O(k), potential decreases by k/2 – O(log n)  O(log n) amortized time

Decrease key? Application: Dijkstra’s shortest path algorithm, others Method: To decrease key of x, detach its half tree, restructure if necessary (If x is the right child of u, no easy way to tell if half order is violated) u x y u y x

How to maintain structure? All previous methods, starting with Fibonacci heaps, change ranks and restructure Some, like Quake heaps (Chan, 2009) and Relaxed heaps (Driscoll et al., 1988), do not restructure during key decrease, but this just postpones restructuring But all that is needed is rank changes: Trees can have arbitrary structure! Rank-Pairing Heaps = rp-heaps Goal is SIMPLICITY

21 Node Ranks Each node has a non-negative integer rank Convention: missing nodes have rank -1 (leaves have rank 0) rank difference of a child = rank of parent - rank of child i-child: node of rank difference i i,j-node: children have rank differences i and j Convention: the child of a root is a 1-child

1 Rank Rules Easy-to-analyze version (type 2): All rank differences are non-negative If rank difference exceeds 2, sibling has rank difference 0 If rank difference is 0, sibling has rank difference at least 2 Simpler but harder-to-analyze version (type 1): If rank difference exceeds 1, sibling has rank difference 0 If rank difference is 0, sibling has rank difference ≥ ≥ ≥ 1 0

Tree Size If n k is minimum number of descendants of a node of rank k, n 0 = 1, n k = n k-1 + n k-2 : Fibonacci numbers n k ≥  k,  = k  log  n

Decrease key x u k k 1 y Detach half treeRestore rank rule 8 0 u 02 6 u 11 6 u 05 u k - 1 u 0-children block propagation of rank decreases from sibling’s subtree

Amortized Analysis Potential of node = sum of rank differences of children if root (= 1) -1 if 1,1-node (= 0) Link is free: One unit pays for link Insert needs 1 unit, meld none + 1 (+1) (0) 11 11

Delete min rank k Each 1,1 needs potential 1, adding at most k in total. Delete min takes O(log n) amortized time 1 1 unit needed 1 0≥ 2 12

Decrease Key Successive rank decreases are non-increasing At most two 1,1’s occur on path of rank decreases – 1,1 becomes 0, j : prev decrease >1, next decrease = 1 1,1 becomes 1,2 : terminal Give each 1,1 one extra unit of potential Each rank decrease releases a unit to pay for decrease: rank diffs of both children decrease by k, rank diff of parent increases by k

Decrease key k k 1 Detach half treeRestore rank rule k - 1 1

Type-1 rp-heaps Max k  lg n Analysis requires a more elaborate potential based on rank differences of children and grandchildren Same bounds as type-2 rp-heaps, provided we preferentially link half trees from disassembly

Summary Rank-pairing heaps combine performance guarantees of Fibonacci heaps with simplicity approaching pairing heaps Type-1 rp-heaps are especially simple, but not simple to analyze Results build on prior work by Peterson, Høyer, and Kaplan and Tarjan, and may be the natural conclusion of this work Simpler methods of doing key decrease are not efficient (see paper) Preliminary experiments show rp-heaps are competitive with pairing heaps on typical input sequences, and better on worst-case sequences

Additional Questions One-tree version of rp-heaps? Yes, but unfair links add losers to the bottom of the loser list instead of the top Decrease key without cascading rank changes? No, with O(log n) time per delete min Maybe, with O(log m) time per delete min need at least one rank decrease Simplify Brodal’s heaps?