Analysis of Fibonacci Heaps: Amortized Cost and Complexity, Slides of Computer Science

An in-depth analysis of fibonacci heaps, focusing on their amortized cost and complexity. Topics covered include insert, remove min, meld, and decrease key operations, as well as the maxdegree property. The document also discusses accounting methods for paying for the actual and amortized costs of these operations.

Typology: Slides

2012/2013

Uploaded on 03/19/2013

dharmakeerti
dharmakeerti 🇮🇳

4.2

(27)

89 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Analysis Of Fibonacci Heaps
Actual
Amortized
Insert O(1) O(1)
Remove min (or max)
O(n) O(log n)
Meld O(1) O(1)
Remove O(n) O(log n)
Decrease key (or
increase) O(n) O(1)
MaxDegree
Let Ni = min # of nodes in any min (sub)tree
whose root has i children.
N0 = 1.
N1 = 2.
6
9
5
Ni , i > 1
Children of b are labeled in the order in which they
became children of b.
c1became a child before c2 did, and so on.
So, when ck became a child of b, degree(b) >= k –1.
degree(ck) at the time when ckbecame a child of b
= degree(b) at the time when ckbecame a child of b
>= k – 1.
b
c1c2 ci
Ni , i > 1
So, current degree(ck) >= max{0, k – 2}.
So, Ni = N0 + (Σ0<=q<=i-2Nq) + 1
= (Σ0<=q<=i-2Nq) + 2.
b
c1c2 ci
Docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Analysis of Fibonacci Heaps: Amortized Cost and Complexity and more Slides Computer Science in PDF only on Docsity!

Analysis Of Fibonacci Heaps

Actual Amortized

Insert O(1) O(1)

Remove min (or max) O(n) O(log n)

Meld O(1) O(1)

Remove O(n) O(log n)

Decrease key (or

increase)

O(n) O(1)

MaxDegree

• Let Ni = min # of nodes in any min (sub)tree

whose root has i children.

• N 0 = 1.

• N 1 = 2.

Ni , i > 1

• Children of b are labeled in the order in which they

became children of b.

 c 1 became a child before c 2 did, and so on.

• So, when ck became a child of b, degree(b) >= k –1.

• degree(ck) at the time when ck became a child of b

= degree(b) at the time when ck became a child of b

>= k – 1.

b

c 1 c 2 …^ …^ ci

Ni , i > 1

• So, current degree(ck) >= max{0, k – 2}.

• So, Ni = N 0 + (Σ 0 <=q<=i- 2 Nq ) + 1

= (Σ 0 <=q<=i- 2 Nq ) + 2.

b

c 1 c 2 …^ …^ ci

Fibonacci Numbers

• F 0 = 0.

• F 1 = 1.

• Fi = Fi-1 + Fi-2, i > 1

= (Σ 0 <=q<=i- 2 Fq ) + 1, i > 1.

• N 0 = 1.

• N 1 = 2.

• Ni = (Σ 0 <=q<=i- 2 Nq ) + 2, i > 1.

• Ni = Fi+2~ ((1 + sqrt(5))/2)i^ , i >= 0.

MaxDegree

• MaxDegree <= logφn, where φ = (1 + sqrt(5))/2.

Accounting Method

• Insert.

 Guessed amortized cost = 2.

 Use 1 unit to pay for the actual cost of the insert and

keep the remaining 1 unit as a credit for a future

remove min operation.

 Keep this credit with the min tree that is created by

the insert operation.

• Meld.

 Guessed amortized cost = 1.

 Use 1 unit to pay for the actual cost of the meld.

Remove Nonmin Element

theNode

Remove Nonmin Element

• Guessed amortized cost = 2logφn + 3.

• Use logφn units to pay for setting parent fields to null.

• Use 1 unit to pay for remaining work not related to

cascading cut.

• Keep 1 unit to pay for the time when node whose

ChildCut field is set to true is cut from its parent, and

another 1 unit for the pairwise combining of the cut

subtree.

• Keep logφn units to pay for possible future pairwise

combining of the new top-level trees created.

Remove Nonmin Element

• Placement of credits.

 Keep 1 unit on each of the newly created top-level

trees.

 Keep 2 units on the node (if any) whose ChildCut

field is set to true by the ensuing cascading cut

operation.

 Discard the remaining credits (if any).

DecreaseKey(theNode, theAmount)

theNode

DecreaseKey(theNode, theAmount)

Guessed amortized cost = 4.

DecreaseKey(theNode, theAmount)

Use 1 unit to pay for work not

related to cascading cut.

DecreaseKey(theNode, theAmount)

Keep 1 unit to pay for possible

future pairwise combining of the

new top-level tree created whose

root is theNode.

Kept as credit on theNode.

DecreaseKey(theNode, theAmount)

Keep 1 unit to pay for the time

when node whose ChildCut field

is set to true is cut from its parent,

and use another 1 unit for the

pairwise combining of the cut

subtree.

DecreaseKey(theNode, theAmount)

•Keep the 2 credits on the node (if

any) whose ChildCut field is set

to true by the ensuing cascading

cut operation.

If there is no such node, discard

the credits.

Who Pays For Cascading Cut?

• Only nodes with ChildCut = true are cut during

a cascading cut.

• The actual cost to cut a node is 1.

• This cost is paid from the 2 units of credit on the

node whose ChildCut field is true. The

remaining unit of credit is kept with the min tree

that has been cut and now becomes a top-level

tree.

Potential Method

• P(i) = Σ[#MinTrees(j) +

2*#NodesWithTrueChildCut(j)]

 #MinTrees(j) is #MinTrees for Fibonacci heap j.

 When Fibonacci heaps A and B are melded, A and

B are no longer included in the sum.

• P(0) = 0

• P(i) >= 0 for all i.