Download presentation

Presentation is loading. Please wait.

Published byConner Elward Modified over 2 years ago

1
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 in many applications. Some graph problems, like minimum spanning tree and single-source-shortest-path problems call decrease-key much more often than other operations

2
Fibonacci Heaps Loosely based on binomial heaps If Decrease-key and Delete are never called, each tree is like a binomial tree

3
Fibonacci Heaps A Fibonacci heap is a collection of heap- ordered trees. Each tree is rooted but unordered. Each node x has pointed p[x] to its parent & child [x] to one of its children Children are linked together in a doubly- linked circular list. Doubly-linked circular list: Removing a node is O(1) and splicing two lists is O(1)

4
Fibonacci Heaps Each node also has degree [x] indicating the number of children of x Each node also has mark [x], a boolean field indicating whether x has lost a child since the last time x was made the child of another node The entire heap is accessed by a pointer min [H] which points to the minimum-key root

5
Amortized Analysis Potential function: (H) = t (H) + 2 m (H) The amortized analysis will depend on there being a known bound D(n) on the maximum degree of any node in an n-node heap When Decrease-Key and Delete are not used, D(n)=log (n)

6
Fibonacci Heap An unordered binomial tree is the same as a binomial tree except that U k = 2 copies of U k-1 where the root of one tree is made any child of the root of the other If an n-node Fibonacci heap is a collection of unordered binomial trees, then D(n)=log(n)

7
Fibonacci Heaps Called a lazy data structure Key idea: Delay work for as long as possible

8
Fibonacci Heap Operations Insert Find-Min Union Extract-Min –Consolidate

9
Analysis of Extract-Min Observe that if all trees are unordered binomial trees before the operation, then they are unordered binomial trees afterwards Only changes to structure of trees: –Children of minimum-root become roots –Two U k trees are linked to form U k+1

10
Analysis of Cost: Actual Cost O(D(n)) children of minimum node. Plus cost of main consolidate loop Size of root list upon calling consolidate is D(n) + t(H) - 1 Every time through loop, one root is linked to another Therefore, total amount of work is D(n)+t(H)

11
Analysis of Cost Actual Cost: D(n) + t(H) Potential Before: t(H) + 2m(H) Potential After: At most (D(n)+1) + 2 m(H) since at most D(n) + 1 roots remain.

12
Decrease Key If heap order is not violated (by the change in key value), then nothing happens If heap order is violated, we cut x from its parent making it a root The mark field has the following effect: as soon as a node loses two children, it is cut from its parent Therefore, when we cut a node x from its parent y, we also set mark [y]

13
Decrease Key If mark [x] is already set, we cut y as well. Therefore, we might have a series of cascading cuts up the tree.

14
Actual Cost of Decrease Key Actual Cost: 1 + cost of cascading cuts Let c be number of times cascading cut is recursively called. Therefore, actual cost is O(c)

15
Change in Potential Let H be original heap. Each recursive call, except for last one, cuts a marked node and clears a marked bit. Afterwards, there are t(H) + c trees & at most m(H) - c + 2 marked nodes ( c - 1 unmarked by cascading cuts & last call may have marked one)

16
Cost of Decrease Key Intuitively: m(H) is weighted twice t(H) because when a marked node is cut, the potential is reduced by 2. One unit pays for the cut & the other compensates for the increase in potential due to t(H)

17
Bounding Maximum Degree To show that Extract-Min & Delete are O(log n), we must show that the upper bound D(n) is O(log n) When all trees are unordered binomial trees, then D(n)= log n But, cuts that take place in Decrease-Key may violate the unordered binomial tree properties.

Similar presentations

OK

CMSC 341 Binomial Queues and Fibonacci Heaps. Basic Heap Operations OpBinary Heap Leftist Heap Binomial Queue Fibonacci Heap insertO(lgN) deleteMinO(lgN)

CMSC 341 Binomial Queues and Fibonacci Heaps. Basic Heap Operations OpBinary Heap Leftist Heap Binomial Queue Fibonacci Heap insertO(lgN) deleteMinO(lgN)

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on digital door lock system Ppt on foreign exchange market in india Ppt on world book day 2016 Ppt on nuclear power in india Ppt on earthquakes and tsunamis Ppt on online shopping site project A ppt on loch ness monster dead Ppt on carbon and its compounds questions Ppt on applications of ultrasound in physics Ppt on collection of data