Fibonacci Heaps & Doubled-Ended Heap Structures

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

Advanced Data structure
Priority Queues And the amazing binary heap Chapter 20 in DS&PS Chapter 6 in DS&AA.
The Heap ADT In this section of notes you will learn about a new abstract data type, the heap, as well how heaps can be used.
Lec 6 Feb 17, 2011  Section 2.5 of text (review of heap)  Chapter 3.
DEAPS By: Michael Gresenz Austin Forrest. Deaps A deap is a double-ended heap that supports the double-ended priority operations of insert, delete-min,
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.
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.
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Binary and Binomial Heaps These lecture slides are adapted from CLRS, Chapters.
PRIORITY QUEUES (HEAPS). Queues are a standard mechanism for ordering tasks on a first-come, first-served basis However, some tasks may be more important.
Binomial Heaps Melalite Ayenew Dec 14, 2000.
CS 3610 Midterm Review.
ADT Table and Heap Ellen Walker CPSC 201 Data Structures Hiram College.
Computer Sciences Department1. Sorting algorithm 3 Chapter 6 3Computer Sciences Department Sorting algorithm 1  insertion sort Sorting algorithm 2.
Chapter 21 Priority Queue: Binary Heap Saurav Karmakar.
WEEK 3 Leftist Heaps CE222 Dr. Senem Kumova Metin CE222_Dr. Senem Kumova Metin.
Cpt S 223 – Advanced Data Structures Priority Queues
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.
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.
+ David Kauchak cs312 Review. + Midterm Will be posted online this afternoon You will have 2 hours to take it watch your time! if you get stuck on a problem,
1 Binomial Tree Binomial tree. n Recursive definition: B k-1 B0B0 BkBk B0B0 B1B1 B2B2 B3B3 B4B4.
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.
CMSC 341 Binomial Queues and Fibonacci Heaps. Basic Heap Operations OpBinary Heap Leftist Heap Binomial Queue Fibonacci Heap insertO(lgN) deleteMinO(lgN)
Mergeable Heaps David Kauchak cs302 Spring Admin Homework 7?
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.
Lecture: Priority Queue. Questions Is array a data structure? What is a data structure? What data structures are implemented by array? Priority queue.
Minimum Spanning Tree Graph Theory Basics - Anil Kishore.
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))
Lecture: Priority Queue
School of Computing Clemson University Fall, 2012
Priority Queue A Priority Queue Set S is made up of n elements: x0 x1 x2 x3 … xn-1 Functions: createEmptySet() returns a newly created empty priority.
CS 201 Data Structures and Algorithms
Heaps (8.3) CSE 2011 Winter May 2018.
Topics covered (since exam 1):
Hashing Exercises.
Source: Muangsin / Weiss
O(lg n) Search Tree Tree T is a search tree made up of n elements: x0 x1 x2 x3 … xn-1 No function (except transverse) takes more than O(lg n) in the.
Data Structures – Week #8
Binomial Tree Adapted from: Kevin Wayne Bk-1 B0 Bk
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.
Ch 6: Heapsort Ming-Te Chi
Topics covered (since exam 1):
Binomial Heap.
ערמות בינומיות ופיבונצ'י
Heap Sort The Heap Data Structure
Fundamental Structures of Computer Science
CE 221 Data Structures and Algorithms
Heap Sort CSE 2011 Winter January 2019.
Closing a Classical Data Structure Problem Gerth Stølting Brodal
Strict Fibonacci Heaps
CS 583 Analysis of Algorithms
Professional Elective-I Advanced Data Structure
Priority Queues An abstract data type (ADT) Similar to a queue
Heaps © 2014 Goodrich, Tamassia, Goldwasser Heaps Heaps
Binary and Binomial Heaps
HEAPS.
Implementation of Dijkstra’s Algorithm
Data Structures – Week #8
Priority Queues Supports the following operations. Insert element x.
Chapter 12 Heap ADT © 2011 Pearson Addison-Wesley. All rights reserved.
CS 6310 Advanced Data Structure Wei-Shian Wang
CSE 373 Data Structures Lecture 12
Heaps & Multi-way Search Trees
Presentation transcript:

Fibonacci Heaps & Doubled-Ended Heap Structures James Rhodes

Introduction After search trees, heaps are the second most studied type of data structure Also, called priority queues, as they keep track of a set of objects using a key value (priority) Supports the following operations: insert (insert an object), find_min (find object with minimum key), and delete_min (delete object with minimum key) Minimum or maximum can be used to create a min_heap or max_heap, respectively A double-ended heap provides both minimum and maximum operations Most important applications are event queues Examples: sweeps in computational geometry, discrete event systems, schedulers, and shortest path

Amortized Analysis Cost of operations are amortized Time to perform a sequence of operations is averaged over all operations Cost of an operation can be small when averaged over a sequence even if single operation is expensive Differs from average-case analysis because probability is not involved Guarantees the average performance of each operation in the worst case

Structure Viewed as a binary tree or an array Each node has a key and an object Parent(i) = Floor(i/2) Left(i) = 2i Right(i) = 2i + 1 Heap Order Property Heap(Parent(i)) <= Heap(i) for min_heap and Heap(Parent(i)) >= Heap(i) for max_heap Half order property no restriction for the left subtree

Fibonacci Heap The Fibonacci heap data structure serves a dual purpose It supports a set of operations that constitutes what is known as a “mergeable heap” Several Fibonacci-heap operations run in constant amortized time, which makes this data structure well suited for applications that invoke these operations frequently The oldest and best known structure that performs the decrease_key operation in constant time Each node n has an integer field n->rank, as well as a state n->state (complete or deficient)

Fibonacci Heap Defining properties: For any node n with n->rank > 1, or n->rank = 1 and n->state = complete, holds n->right = NULL, and If n->state = complete, then on the left path below n->right there are n->rank nodes, which have rank at least n->rank − 1, n->rank − 2, . . . , 0, in some sequence. If n->state = deficient, then on the left path below n->right there are n->rank − 1 nodes, which have rank at least n->rank − 2, n->rank − 3, . . . , 0, in some sequence. For any node n with n->rank = 0, or n->rank = 1 and n->state = deficient, holds n->right = NULL

Fibonacci Heap If deficient nodes are not allowed, strictly decreasing rank along the leftmost path is demanded, and the first rule is strengthened to: For any node n of with n->rank > 0, holds n->right = NULL, and on the left path below n->right, there are n->rank nodes, which have rank exactly n->rank − 1, n->rank − 2, . . . , 0, in decreasing sequence. Then that will be a binomial heap structure, thus the Fibonacci heap is a structural relaxation of the binomial heap

Fibonacci Heap Fibonacci Heap Structure: The Nodes Are Labeled by Rank and Deficiency Status

Fibonacci Heap The minimum number f (k) of nodes in a block of rank k satisfies the recursion f (k) = f (k − 2) + f (k − 3)+· · ·+f (1) + f (0) + 1 Using f (k − 1) = f (k − 3)+· · ·+f (1) + f (0) + 1, the recursion can be rewritten as f (k) = f (k − 1) + f (k − 2) This is the recurrence equation for the Fibonacci sequence which is where the structure gets its name The starting values are f (0) = f (1) = 1

If the equation is solved we get Fibonacci Heap If the equation is solved we get

Fibonacci Heap Theorem. The Fibonacci heap structure supports the operations find_min, insert, merge, delete_min, and decrease key, with find min, insert, and merge in O(1) time, decrease key in amortized O(1) time, and delete_min in amortized O(log n) time.

Operations: insert find_min merge delete_min decrease_key Fibonacci Heap Operations: insert find_min merge delete_min decrease_key

Fibonacci Heap n = number of elements in priority queue †amortized Operation Linked List Binary Heap Binomial Heap Fibonacci Heap † Relaxed Heap make-heap 1 1 1 1 1 is-empty 1 1 1 1 1 insert 1 log n log n 1 1 delete-min n log n log n log n log n decrease-key n log n log n 1 1 delete n log n log n log n log n union 1 n log n 1 1 find-min n 1 log n 1 1 n = number of elements in priority queue †amortized

Double-ended Heap A min and max heap combined Each element is inserted into both heaps Insert requires 2 operations Delete requires a delete_min or delete_max in the corresponding heap and arbitrary delete in the other Theorem. There is a double-ended heap that supports insert , find-min , find-max, merge in O(1) ; and delete-min , delete-max in O(log n) worst-case .

References Advanced Data Structures, Peter Brass, Cambridge University Press, 2008 Introduction to Algorithms, Thomas H Cormen, Charles E Leiserson, Ronald L Rivest, Clifford Stein MIT Press, 2001 Wikipedia, Wikimedia Foundation, 2018, www.wikipedia.org, accessed 14 Feb 2019.

Questions

Thank You