1 / 22

Analysis Of Fibonacci Heaps

Analysis Of Fibonacci Heaps. 6. 5. 9. MaxDegree. Let N i = min # of nodes in any min (sub)tree whose root has i children. N 0 = 1. N 1 = 2. b. …. …. c i. c 1. c 2. N i , i > 1. Children of b are labeled in the order in which they became children of b .

lavadaa
Download Presentation

Analysis Of Fibonacci Heaps

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Analysis Of Fibonacci Heaps

  2. 6 5 9 MaxDegree • Let Ni = min # of nodes in any min (sub)tree whose root has i children. • N0 = 1. • N1 = 2.

  3. b … … ci c1 c2 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.

  4. b … … ci c1 c2 Ni , i > 1 • So, current degree(ck) >= max{0, k – 2}. • So, Ni = N0 + (S0<=q<=i-2Nq ) + 1 =(S0<=q<=i-2Nq ) + 2.

  5. Fibonacci Numbers • F0 = 0. • F1 = 1. • Fi = Fi-1 + Fi-2, i > 1 =(S0<=q<=i-2Fq ) + 1, i > 1. • N0 = 1. • N1 = 2. • Ni =(S0<=q<=i-2Nq ) + 2, i > 1. • Ni =Fi+2~ ((1 + sqrt(5))/2)i , i >= 0.

  6. MaxDegree • MaxDegree <= logfn, where f =(1 + sqrt(5))/2.

  7. 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.

  8. 6 1 5 theNode 3 9 7 4 2 8 10 9 5 4 5 9 7 6 6 8 Remove Nonmin Element

  9. 1 5 10 5 3 9 7 9 2 6 8 9 4 5 7 6 6 8 Remove Nonmin Element • Guessed amortized cost = 2logfn + 3. • Use logfn units to pay for setting parent fields to null for subtrees of deleted node. • Use 1 unit to pay for remaining work not related to cascading cut.

  10. 1 5 10 5 3 9 7 9 2 6 8 9 4 5 7 6 6 8 Remove Nonmin Element • Keep logfn units to pay for possible future pairwise combining of the new top-level trees created. • Kept as 1 credit per new top-level tree. • Discard excess credits (if any).

  11. 1 5 10 5 3 9 7 9 2 6 8 9 4 5 7 6 6 8 Remove Nonmin Element • 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.

  12. 1 5 10 5 3 9 7 9 2 6 8 9 4 5 7 6 6 8 Remove Nonmin Element • 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.

  13. 6 1 5 theNode 3 9 7 4 2 8 10 9 5 4 5 9 7 6 6 8 DecreaseKey(theNode, theAmount)

  14. DecreaseKey(theNode, theAmount) 0 1 6 5 3 10 5 7 9 2 9 8 9 4 5 7 6 6 Guessed amortized cost = 4. 8

  15. 0 1 6 5 3 10 5 7 9 2 9 8 9 4 5 7 6 6 8 DecreaseKey(theNode, theAmount) Use 1 unit to pay for work not related to cascading cut.

  16. 0 1 6 5 3 10 5 7 9 2 9 8 9 4 5 7 6 6 8 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.

  17. 0 1 6 5 3 10 5 7 9 2 9 8 9 4 5 7 6 6 8 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.

  18. 0 1 6 5 3 10 5 7 9 2 9 8 9 4 5 7 6 6 8 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.

  19. Remove Min • Guessed amortized cost = 3logfn. • Actual cost <= 2logfn – 1 + #MinTrees. • Allocation of amortized cost. • Use 2logfn – 1 to pay part of actual cost. • Keep remaining logfn + 1 as a credit to pay part of the actual cost of a future remove min operation. • Put 1 unit of credit on each of the at most logfn + 1 min trees left behind by the remove min operation. • Discard the remaining credits (if any).

  20. Paying Actual Cost Of A Remove Min • Actual cost <= 2logfn – 1 + #MinTrees • How is it paid for? • 2logfn – 1 ispaid for from the amortized cost of the remove min. • #MinTrees ispaid by the 1 unit credit on each of the min trees in the Fibonacci heap just prior to the remove min operation.

  21. 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.

  22. Potential Method • P(i) = S[#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.

More Related