fibonacci heaps
play

Fibonacci Heaps Group: N = NP Leader: T ang Hao Member: Chen - PowerPoint PPT Presentation

Fibonacci Heaps Group: N = NP Leader: T ang Hao Member: Chen Zhiqin Liao Mingding Shen Bingyu Introduction Binominal Heap Fibonacci Heap a better amortized running time than a binomial heap developed by Michael L. Fredman and


  1. Fibonacci Heaps Group: N = NP Leader: T ang Hao Member: Chen Zhiqin Liao Mingding Shen Bingyu

  2. Introduction • Binominal Heap • Fibonacci Heap – a better amortized running time than a binomial heap – developed by Michael L. Fredman and Robert E. Tarjan in 1984 – first published in a scientific journal in 1987 – The name of Fibonacci heap comes from Fibonacci numbers whic h are used in the running time analysis

  3. Introduction A faster implementation of Prim’s MST algorithm and Dijkstra’s Shortest Paths algorithm. Operation running using time times insert(v, h) O(1) |V| delete- O(log n) |V| min(h) decrease(v, O(1) m(edges) Using Fibonacci Heaps, the total running time of Dij Δ) kstra or Prim is O(m + n log n)

  4. Binomial Trees Binomial Trees are defined inductively.

  5. Binomial Trees(cont.) Proposition 1 Two trees Bk can be merged into one Bk+1 in constant time. We call this the merg e operation. Proof. Proposition 2 A Bk tree contains exactly 2k nodes. Proof.

  6. Binomial Heaps  A collection of Binomial trees.  For each rank k, at most one tree Bk is containe d.  Each of the trees satisfy the heap property.

  7. Binomial Heaps(cont.) Lemma 3 A Binomial Heap (over an n-element u niverse) contains at most O(log n) trees. Proof.

  8. Comparisons Operation Bio. Heap Fib. Heap insert(v, h) O(log n) O(1) delete-min(h) O(log n) O(log n) decrease(v, O(log n) O(1) Δ) Our goal is to implement the insert operation in time O(1).

  9. Insert

  10. Delete_min

  11. Delete_min.cont

  12. Delete_min.cont

  13. Delete_min.cont

  14. Delete_min.cont

  15. Delete_min.cont

  16. Delete_min.cont

  17. Delete_min.cont

  18. Delete_min.cont

  19. Delete_min.cont

  20. Delete_min.cont

  21. Delete_min.cont

  22. Merge Credit 1 1 Credit Credit 1 + 1 – 1 = 1 Credit

  23. Analysis Push off the meld operation from insert to delete_min.  Merge credit: one unit operation to merge two trees together, it tak es O(1) time.  Insert: each tree is given on merge credit. So the insert operation do es one insert operation and one merge credit.  Delete_min: we first meld the trees together. When two trees merged to gether to one tree, we use one merge credit, and the result is one new tree with one merge credit. So meld is free. Delete_min only cost O(max deg) to search all the trees and O(deg(min)) to put its sons into the root list.

  24. decrease add a decrease operation that runs in (amort ized) time O(1) -- decrease(v, Δ ).

  25. Decrease.cont decrease 23 to 3

  26. Decrease.cont Decrease 42 to 2

  27. Decrease.cont

  28. Decrease If we decrease the value for some node v: • Let p be the parent of v. • Delete v and its subtree and make them a new tree. • If the parent of v, p, has no other child been removed, then that’s all we do. • If p has already lost a child, we also remove p itself and its remaining subtree. • Consider p as a child of its parent p0, and do 3~5.

  29. Cut Credit

  30. Cut Credit Cut this node !

  31. Cut Credit 1 merge credit 1 cut credit 1 merge credit

  32. Cut Credit 1 merge credit 1 cut credit 1 merge credit

  33. Cut Credit 1 merge credit 1 merge credit 2 cut credit 2 merge credit

  34. Cut Credit 1 merge credit 1 merge credit 2 cut credit 2 merge credit

  35. Cut Credit 1 merge credit 1 merge credit 1 merge credit 1 cut credit 1 merge credit

  36. Analysis  Cut credit: one unit operation to cut one subtree, it takes O (1) time.  decrease: the decrease function cuts the subtree, give the n ew tree one merge credit and give the parent of the node one merge credit and one cut credit. It takes O(1) time.  Iteration cut: if the nodes has lost two children, it will contain two merge credits and two cut credits. Use one cut credit to cut the subtree, give one merge credit to the new tree, give o ne merge credit and one cut credit to the parent of it. Then t he iteration cut is free.

  37. Size of a tree in a Fib Heap Proof.

  38. Analysis Sk: The smallest number of nodes that could be in a t ree of rank k. Sk = 1 + S0 + S0 + S1 + S2 + . . . + Sk 3 + Sk 2 − − Sk 1 = 1 + S0 + S0 + S1 + S2 + . . . + Sk 4 + Sk 3 − − − Sk Sk 1 = Sk 2 − − − Fibonacci numbers

  39. Analysis Proof.

  40. Worst Case of Heap Size S 3 S S 2 1 1 S S 0 0 S 4

  41. Conclusion After the clean-up operation, the delete_min operati on only needs to check O(log n) roots, and hence t erminates in O(log n) steps. the operations in Prim’s or Dijkstra’s algorithm take time O(m + n + n log n) = O(m + n log n).

  42. References 1. https://en.wikipedia.org/wiki/Fibonacci_heap https://en.wikipedia.org/wiki/Binomial_heap 2. Thomas H.; Leiserson, Charles E., Rivest, Ronald L. (1990). Introduction to Algorith 3. ms (1st ed.). MIT Press and McGraw-Hill. ISBN 0-262-03141-8. http://www.cnblogs.com/skywang12345/p/3659060.html 4. http://www-bcf.usc.edu/~dkempe/teaching/fibonacci.pdf 5.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend