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.

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

DATA STRUCTURES AND ALGORITHMS Lecture Notes 9 Prepared by İnanç TAHRALI.
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)
Advanced Data structure
Rank-Pairing Heaps Robert Tarjan, Princeton University & HP Labs Joint work with Bernhard Haeupler and Siddhartha Sen, ESA
1 Self-Adjusting Data Structures. 2 Lists [D.D. Sleator, R.E. Tarjan, Amortized Efficiency of List Update Rules, Proc. 16 th Annual ACM Symposium on Theory.
CS 315 March 24 Goals: Heap (Chapter 6) priority queue definition of a heap Algorithms for Insert DeleteMin percolate-down Build-heap.
More sorting algorithms: Heap sort & Radix sort. Heap Data Structure and Heap Sort (Chapter 7.6)
Heaps and heapsort COMP171 Fall Sorting III / Slide 2 Motivating Example 3 jobs have been submitted to a printer in the order A, B, C. Sizes: Job.
CISC220 Fall 2009 James Atlas Nov 13: Heap Implementations, Graphs.
Rank-Pairing Heaps Bernhard Haeupler, Siddhartha Sen, and Robert Tarjan, ESA
CSE 373 Data Structures Lecture 12
Dijkstra/Prim 1 make-heap |V| insert |V| delete-min |E| decrease-key Priority Queues make-heap Operation insert find-min delete-min union decrease-key.
Source: Muangsin / Weiss1 Priority Queue (Heap) A kind of queue Dequeue gets element with the highest priority Priority is based on a comparable value.
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
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.
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Binary and Binomial Heaps These lecture slides are adapted from CLRS, Chapters.
Fundamental Structures of Computer Science March 02, 2006 Ananda Guna Binomial Heaps.
ANALYSIS OF SOFT HEAP Varun Mishra April 16,2009.
1 Binomial heaps, Fibonacci heaps, and applications.
Algorithms 2005 Ramesh Hariharan. Amortization in Dynamic Algorithms A single insertion/deletion might take say O(log n) time Does a sequence of n insertions.
Strict Fibonacci Heaps Gerth Stølting Brodal Aarhus University George Lagogiannis Robert Endre Tarjan Agricultural University of Athens Princeton University.
Algorithms and Data Structures Gerth Stølting Brodal Computer Science Day, Department of Computer Science, Aarhus University, May 25, 2012.
Binomial heaps, Fibonacci heaps, and applications
§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.
Binary Trees, Binary Search Trees RIZWAN REHMAN CENTRE FOR COMPUTER STUDIES DIBRUGARH UNIVERSITY.
Algorithms and Data Structures Gerth Stølting Brodal Computer Science Day, Department of Computer Science, Aarhus University, May 25, 2012.
WEEK 3 Leftist Heaps CE222 Dr. Senem Kumova Metin CE222_Dr. Senem Kumova Metin.
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:
Change Keys in heaps Fibonacci heap Zhao Xiaobin.
1 Binomial Tree Binomial tree. n Recursive definition: B k-1 B0B0 BkBk B0B0 B1B1 B2B2 B3B3 B4B4.
Data Structure II So Pak Yeung Outline Review  Array  Sorted Array  Linked List Binary Search Tree Heap Hash Table.
Binomial Tree B k-1 B0B0 BkBk B0B0 B1B1 B2B2 B3B3 B4B4 Adapted from: Kevin Wayne B k : a binomial tree B k-1 with the addition of a left child with another.
Gerth stølting Brodal 1 Closing a Classical Data Structure Problem Gerth Stølting Brodal : Strict Fibonacci Heaps joint work with George Lagogiannis Robert.
Data StructuresData Structures Priority Queue. Recall Queues FIFO:First-In, First-Out Some contexts where this seems right? Some contexts where some things.
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)
CS6045: Advanced Algorithms Sorting Algorithms. Heap Data Structure A heap (nearly complete binary tree) can be stored as an array A –Root of tree is.
1 Chapter 6 Heapsort. 2 About this lecture Introduce Heap – Shape Property and Heap Property – Heap Operations Heapsort: Use Heap to Sort Fixing heap.
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.
Self-Adjusting Data Structures
Data Structures Binomial Heaps Fibonacci Heaps Haim Kaplan & Uri Zwick
Binomial heaps, Fibonacci heaps, and applications
Heaps 8/2/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser,
Heaps Binomial Heaps Lazy Binomial Heaps 1.
Source: Muangsin / Weiss
Priority Queues MakeQueue create new empty queue
A simpler implementation and analysis of Chazelle’s
ערמות בינומיות ופיבונצ'י
Fundamental Structures of Computer Science
Closing a Classical Data Structure Problem Gerth Stølting Brodal
Strict Fibonacci Heaps
Heaps © 2014 Goodrich, Tamassia, Goldwasser Heaps Heaps
Binary and Binomial Heaps
Binomial heaps, Fibonacci heaps, and applications
Fibonacci Heaps.
Binomial heaps, Fibonacci heaps, and applications
Priority Queues Supports the following operations. Insert element x.
CS 6310 Advanced Data Structure Wei-Shian Wang
Fibonacci Heaps & Doubled-Ended Heap Structures
Fundamental Structures of Computer Science II
Presentation transcript:

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 key with min priority  Meld(Q 1,Q 2 )merge two sets  Empty(Q)returns if empty  Size(Q)returns #keys  FindMin(Q)returns key with min priority 1

Priority Queues – Ideal Times MakeQueue, Meld, Insert, Empty, Size, FindMin: O(1) Delete, DeleteMin: O(log n) Thm 1) Meld O(n 1-ε )  DeleteMin Ω(log n) 2) Insert, Delete O(t)  FindMin Ω(n/2 O(t) ) 1)Follows from Ω(n∙log n) sorting lower bound 2) [G.S. Brodal, S. Chaudhuri, J. Radhakrishnan,The Randomized Complexity of Maintaining the Minimum. In Proc. 5th Scandinavian Workshop on Algorithm Theory, volume 1097 of Lecture Notes in Computer Science, pages Springer Verlag, Berlin, 1996] 2

Binomial Queues  Binomial tree – each node stores a (k,p) and satisfies heap order with respect to priorities – all nodes have a rank r (leaf = rank 0, a rank r node has exactly one child of each of the ranks 0..r-1)  Binomial queue – forest of binomial trees with roots stored in a list with strictly increasing root ranks [Jean Vuillemin, A data structure for manipulating priority queues, Communications of the ACM archive, Volume 21(4), , 1978]

Problem Implement binomial queue operations to achieve the ideal times in the amortized sense Hints 1)Two rank i trees can be linked to create a rank i+1 tree in O(1) time 2)Potential Φ = max rank + #roots xy x y rr r r+1 link x ≥ y 4

Dijkstra’s Algorithm (Single source shortest path problem) n x Insert + n x DeleteMin + m x DecreaseKey Binary heaps / Binomial queues : O((n + m)∙log n) Algorithm Dijkstra(V, E, w, s) Q := MakeQueue dist[s] := 0 Insert(Q, s, 0) for v  V \ { s } do dist[v] := +∞ Insert(Q, v, +∞) while Q ≠  do v := DeleteMin(Q) foreach u : (v, u)  E do if u  Q and dist[v]+w(v, u) < dist[u] then dist[u] := dist[v]+w(v, u) DecreaseKey(u, dist[u]) 5

Priority Bounds Empty, FindMin, Size, MakeQueue – O(1) worst-case time AmortizedWorst-case  Dijkstra’s Algorithm O(m + n∙log n) Binomial Queues [Vuillemin 78] Fibonacci Heaps [Fredman, Tarjan 84] Run-Relaxed Heaps [Driscoll, Gabow, Shrairman, Tarjan 88][Brodal 96] Insert1111 Meld11-1 Deletelog n DeleteMinlog n DecreaseKeylog n111 (and Minimum Spanning Tree O(m∙log* n)) 6

Fibonacci Heaps  F-tree – heap order with respect to priorities – all nodes have a rank r  {degree, degree + 1} (r = degree + 1  node is marked as having lost a child) – The i’th child of a node from the right has rank ≥ i - 1  Fibonacci Heap – forest (list) of F-trees (trees can have equal rank) [Fredman, Tarjan, Fibonacci Heaps and Their Use in Improved Network Algorithms, Journal of the ACM, Volume 34(3), , 1987]

Proof A rank r node has at least 2 children of rank ≥ r – 3. By induction subtree size is at least 2└ r/3 ┘ □ ( in fact the size is at least  r, where  =(1+  5)/2 ) Fibonnaci Heap Property Thm Max rank of a node in an F-tree is O(log n) 8

Hints 1)Two rank i trees can be linked to create a rank i+1 tree in O(1) time 2)Eliminating nodes violating order or nodes having lost two children 3)Potential Φ = 2∙marks + #roots Problem Implement Fibonacci Heap operations with amortized O(1) time for all operations, except O(log n) for deletions xy x y rr r r+1 link x ≥ y x r cut degree(x) = d ≤ r-2 y x d y 9

Implemenation of Fibonacci Heap Operations FindMin Maintain pointer to min root InsertCreate new tree = new rank 0 node +1 JoinConcatenate two forests unchanged Delete DecreaseKey -∞ + DeleteMin DeleteMin Remove min root -1 + add children to forest +O(log n ) + bucketsort roots by rank only O(log n ) not linked below + link while two roots equal rank -1 each DecreaseKeyUpdate priority + cut edge to parent +3 + if parent now has r – 2 children, recursively cut parent edges -1 each, +1 final cut * = potential change 10

Worst-Case Operations (without Join) Basic ideas  Require ≤ max-rank + 1 trees in forest (otherwise  rank r where two trees can be linked)  Replace cutting in F-trees by having O(log n) nodes violating heap order  Transformation replacing two rank r violations by one rank r+1 violation [Driscoll, Gabow, Shrairman, Tarjan, Relaxed Heaps: An Alternative to Fibonacci Heaps with Applications to Parallel Computation, Communications of the ACM, Volume 34(3), , 1987] 11