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.

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

Advanced Data structure
Analysis Of Binomial Heaps. Operations Insert  Add a new min tree to top-level circular list. Meld  Combine two circular lists. Remove min  Pairwise.
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.
By Amber McKenzie and Laura Boccanfuso. Dijkstra’s Algorithm Question: How do you know that Dijkstra’s algorithm finds the shortest path and is optimal.
Analysis Of Fibonacci Heaps. MaxDegree Let N i = min # of nodes in any min (sub)tree whose root has i children. N 0 = 1. N 1 =
Min-Max Heaps A double-ended priority queue is a data structure that supports the following operations: inserting an element with an arbitrary key deleting.
Shortest Path Problems Directed weighted graph. Path length is sum of weights of edges on path. The vertex at which the path begins is the source vertex.
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
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.
Chapter 9: Graphs Spanning Trees Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Binary and Binomial Heaps These lecture slides are adapted from CLRS, Chapters.
1 Binomial heaps, Fibonacci heaps, and applications.
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.
Chapter 9 Heap Structures
Chap 9 Priority Queues. Operations supported by priority queue The functions that have been supported: –SP1: Return an element with minmum priority –SP2:
B + -Trees Same structure as B-trees. Dictionary pairs are in leaves only. Leaves form a doubly-linked list. Remaining nodes have following structure:
Fibonacci Heaps.
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.
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
Splay Trees Binary search trees.
Chapter 11: Multiway Search Trees
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,
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 Binomial Heaps Lazy Binomial Heaps 1.
Heaps © 2010 Goodrich, Tamassia Heaps Heaps
Splay Trees Binary search trees.
Priority Queues MakeQueue create new empty queue
Interval Heaps Complete binary tree.
Shortest Path Problems
Shortest Path Problems
Pairing Heaps Actual Complexity.
Initializing A Max Heap
Part-D1 Priority Queues
Minimum-Cost Spanning Tree
A simpler implementation and analysis of Chazelle’s
Minimum-Cost Spanning Tree
ערמות בינומיות ופיבונצ'י
Outline This topic covers Prim’s algorithm:
Minimum-Cost Spanning Tree
CS 583 Analysis of Algorithms
Fundamental Structures of Computer Science
Strict Fibonacci Heaps
Shortest Path Problems
Fibonacci Heaps Remove arbitrary is useful in (for example) correspondence structures.
Heaps © 2014 Goodrich, Tamassia, Goldwasser Heaps Heaps
Binary and Binomial Heaps
Binomial heaps, Fibonacci heaps, and applications
Shortest Path Problems
Shortest Path Problems
Fibonacci Heaps.
Binomial heaps, Fibonacci heaps, and applications
Priority Queues Supports the following operations. Insert element x.
Pairing Heaps Actual Complexity
Heaps & Multi-way Search Trees
A Heap Is Efficiently Represented As An Array
Splay Trees Binary search trees.
Heaps Chapter 6 Section 6.9.
Chapter 9: Graphs Spanning Trees
Minimum-Cost Spanning Tree
Presentation transcript:

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 and reinsert). General simulation environment: increase/decrease priority after entry, item departs without service (arbitrary remove), meld 2 queues because 1 server dies.

Analysis FibonacciAnalysis.ppt Video www.cise.ufl.edu/~sahni/cop5536; Internet Lectures; not registered COP5536_FHA.rm

Single Source All Destinations Shortest Paths 1 2 3 4 5 6 7 16 8 10 14

Greedy Single Source All Destinations Known as Dijkstra’s algorithm. Let d(i) be the length of a shortest one edge extension of an already generated shortest path, the one edge extension ends at vertex i. The next shortest path is to an as yet unreached vertex for which the d() value is least. After the next shortest path is generated, some d() values are updated (decreased).

Operations On d() Remove min. Decrease d(). Array. Min heap. Done O(n) times, where n is the number of vertices in the graph. Decrease d(). Done O(e) times, where e is the number of edges in the graph. Array. O(n2) overall complexity. Min heap. O(nlog n + elog n) overall complexity. Fibonacci heap. O(nlog n + e) overall complexity.

Prim’s Min-Cost Spanning Tree Algorithm Array. O(n2) overall complexity. Min heap. O(nlog n + elog n) overall complexity. Fibonacci heap. O(nlog n + e) overall complexity.

Min Fibonacci Heap Collection of min trees. The min trees need not be Binomial trees.

Node Structure Degree, Child, Data Left and Right Sibling Parent Used for circular doubly linked list of siblings. Parent Pointer to parent node. ChildCut True if node has lost a child since it became a child of its current parent. Set to false by remove min, which is the only operation that makes one node a child of another. Undefined for a root node. Doubly linked list … remove arbitrary uses external pointers to nodes and also requires deletion of a tree from its doubly linked circular list. So, we cannot copy an element from the next node as is done in the delete of an arbitrary node from a singularly linked circular list. Further, there is a parent pointer to a node. If you move an element you must change the parent pointer from its children. This would take O(children) time. Parent field needed for decreaseKey and cascading cut as well. Decrease key also needs external pointers to nodes in the heap. Arb delete and decrease key may cause a node to lose a child.

Fibonacci Heap Representation 6 4 9 5 8 7 3 1 2 A Try to remove 4. If you copy the 5 over, there is an external pointer to 5’s former node And also a parent pointer from 6 to 5. Degree, Parent and ChildCut fields not shown.

Remove(theNode) theNode points to the Fibonacci heap node that contains the element that is to be removed. theNode points to min element => do a remove min. In this case, complexity is the same as that for remove min.

Remove(theNode) theNode 8 7 3 1 6 5 9 2 4 10 theNode Remove theNode from its doubly linked sibling list.

Remove(theNode) 8 7 3 1 6 5 9 2 4 10 Must make parent pointers in theNode’s children equal to null. Combine top-level list and children of theNode setting parent pointers of the children of theNode to null.

Remove(theNode) 10 1 6 5 5 3 7 9 9 2 8 4 9 5 6 7 6 No pairwise combining of equal-degree trees. Child pointer from parent (if any) needs to be changed. Heap pointer is unchanged. Parent pointers of theNode’s children need to be set to null. Actual complexity is degree of theNode. 8

DecreaseKey(theNode, theAmount) 8 7 3 1 6 5 9 2 4 10 theNode DecreaseKey(theNode,4). Possible update of min element pointer. Parent pointer set to null and child pointer from parent may need to be reset. Actual complexity is O(1). But becomes O(n) when cascading cut is factored in. You could do pairwise combining of equal degree nodes, but this would make amortized complexity O(log n) rather than O(1). If theNode is not a root and new key < parent key, remove subtree rooted at theNode from its doubly linked sibling list. Insert into top-level list.

DecreaseKey(theNode, theAmount) 8 7 3 1 6 5 9 2 4 6 5 10 5 9 9 Update heap pointer if necessary

Cascading Cut When theNode is cut out of its sibling list in a remove or decrease key operation, follow path from parent of theNode to the root. Encountered nodes (other than root) with ChildCut = true are cut from their sibling lists and inserted into top-level list. Stop at first node with ChildCut = false. For this node, set ChildCut = true.

Cascading Cut Example 8 7 3 1 6 5 9 2 4 theNode T F Decrease key by 2.

Cascading Cut Example 1 6 3 F 7 2 9 8 8 4 T 9 5 9 6 T 7 6

Cascading Cut Example 1 6 7 3 F 7 2 9 8 8 4 T 9 5 9 6 6

Cascading Cut Example 1 6 7 4 3 F 7 2 9 8 6 8 9 5 9 6

Cascading Cut Example 8 7 3 1 6 5 9 2 4 T Actual complexity of cascading cut is O(n), because now the tree height may be O(n). Do ops to create a B2 (height = 3). Now do a decrease key to get a chain of height (length) 3 and a B0. Do 2 inserts, a remove min, and a decrease key to get a chain of height 4 and B0. We can increase height by 1 each time we do 2 inserts, a remove min, and a decrease key. So, height is O(n), where n is number of operations (or number of elements in tree). Actual complexity of cascading cut is O(h) = O(n).