fibonacci heap
play

Fibonacci Heap Group Minus One Second December 6, 2016 Group Minus - PowerPoint PPT Presentation

Introduction Fibonacci Heap Time Complexity Analysis Fibonacci Heap Group Minus One Second December 6, 2016 Group Minus One Second Fibonacci Heap Introduction Fibonacci Heap Time Complexity Analysis Outline Introduction Motivation


  1. Introduction Fibonacci Heap Time Complexity Analysis Fibonacci Heap Group Minus One Second December 6, 2016 Group Minus One Second Fibonacci Heap

  2. Introduction Fibonacci Heap Time Complexity Analysis Outline Introduction Motivation Performance Goal Fibonacci Heap Structure Rank Insert Delete Min Decrease Key Time Complexity Analysis Amortized Analysis Insert Complexity Delete Min Complexity Decrease Key Complexity Group Minus One Second Fibonacci Heap

  3. Introduction Motivation Fibonacci Heap Performance Goal Time Complexity Analysis Motivation I Design a data structure that supports the following operations I Insert( x ) I DeleteMin() I DecreaseKey( u , v ) 12 2 9 30 7 5 15 3 21 Group Minus One Second Fibonacci Heap

  4. Introduction Motivation Fibonacci Heap Performance Goal Time Complexity Analysis Motivation I Design a data structure that supports the following operations I Insert( x ) I DeleteMin() I DecreaseKey( u , v ) Insert(10) 12 10 2 9 30 7 5 15 3 21 Group Minus One Second Fibonacci Heap

  5. Introduction Motivation Fibonacci Heap Performance Goal Time Complexity Analysis Motivation I Design a data structure that supports the following operations I Insert( x ) I DeleteMin() I DecreaseKey( u , v ) DeleteMin() 12 10 2 9 30 7 5 15 3 21 Group Minus One Second Fibonacci Heap

  6. Introduction Motivation Fibonacci Heap Performance Goal Time Complexity Analysis Motivation I Design a data structure that supports the following operations I Insert( x ) I DeleteMin() I DecreaseKey( u , v ) DecreaseKey(21, 17) 12 10 9 30 7 5 15 3 21 17 Group Minus One Second Fibonacci Heap

  7. Introduction Motivation Fibonacci Heap Performance Goal Time Complexity Analysis Performance Goal I Our performance goals of this data structure I Insert( x ): O (1) I DeleteMin(): O ( log n ) I DecreaseKey( u , v ): O (1) Group Minus One Second Fibonacci Heap

  8. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Structure I Fibonacci heap is essentially a set of heap-ordered trees. roots heap-ordered tree 23 17 24 7 3 30 46 18 26 52 41 35 39 44 Group Minus One Second Fibonacci Heap

  9. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Rank I The rank of a tree in a Fibonacci heap is the number of children of the root. rank = 1 rank = 2 rank = 0 rank = 0 rank = 3 23 17 24 7 3 30 26 46 18 52 41 35 39 44 Group Minus One Second Fibonacci Heap

  10. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Insert I To insert a new value x into Fibonacci Heap H , simply create a new tree that contains only x and add it to H . I Example: Insert(21) 21 17 24 23 7 3 30 26 46 18 52 41 35 39 44 Group Minus One Second Fibonacci Heap

  11. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Insert I To insert a new value x into Fibonacci Heap H , simply create a new tree that contains only x and add it to H . I Example: Insert(21) 17 24 23 7 21 3 30 26 46 18 52 41 35 39 44 Group Minus One Second Fibonacci Heap

  12. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Delete Min I The minimum must be one of the roots. I But there can be too many( Ω ( n )) roots! I Example: DeleteMin() for the heap below 23 17 46 24 7 21 3 Group Minus One Second Fibonacci Heap

  13. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Delete Min I We introduce consolidation , a process of merging trees of the same rank. merge 24 23 21 17 7 3 30 26 46 18 52 41 35 39 44 Group Minus One Second Fibonacci Heap

  14. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Delete Min I We introduce consolidation , a process of merging trees of the same rank. merge 17 24 7 21 3 30 26 46 18 52 41 23 35 39 44 Group Minus One Second Fibonacci Heap

  15. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Delete Min I We introduce consolidation , a process of merging trees of the same rank. merge 24 7 21 3 26 46 17 18 52 41 23 30 35 39 44 Group Minus One Second Fibonacci Heap

  16. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Delete Min I We introduce consolidation , a process of merging trees of the same rank. merge 7 21 3 17 24 23 18 52 41 30 26 46 39 44 35 Group Minus One Second Fibonacci Heap

  17. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Delete Min I We introduce consolidation , a process of merging trees of the same rank. 21 3 18 52 41 7 39 17 24 44 23 30 46 26 35 Group Minus One Second Fibonacci Heap

  18. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Delete Min I After consolidation, we simply remove the minimum value and leave the remaining trees in the heap. 18 52 41 7 21 17 24 39 44 23 30 26 46 35 Group Minus One Second Fibonacci Heap

  19. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Decrease Key I Case 1: we can finish the operation immediately I Example: decreaseKey(46, 36) 18 52 41 7 21 17 24 39 44 23 30 26 46 35 Group Minus One Second Fibonacci Heap

  20. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Decrease Key I Case 1: we can finish the operation immediately I Example: decreaseKey(46, 36) 18 52 41 7 21 17 24 39 44 23 30 26 36 35 Group Minus One Second Fibonacci Heap

  21. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Decrease Key I Case 2: we have to cut the whole subtree rooted at u I Example: DecreaseKey(26, 16) 18 52 41 7 21 17 24 39 44 23 30 26 46 35 Group Minus One Second Fibonacci Heap

  22. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Decrease Key I Case 2: we have to cut the whole subtree rooted at u I Example: DecreaseKey(26, 16) 18 52 41 7 21 17 24 39 44 23 30 16 46 35 Group Minus One Second Fibonacci Heap

  23. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Decrease Key I Case 2: we have to cut the whole subtree rooted at u I Example: DecreaseKey(26, 16) 18 52 41 7 21 16 17 24 39 44 23 35 30 46 Group Minus One Second Fibonacci Heap

  24. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Decrease Key I But wait! Under this strategy, something undesirable might happen. I The example below shows that this strategy can hurt the performance of DeleteMin operation. I Example: Group Minus One Second Fibonacci Heap

  25. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Decrease Key with Marks One node is marked if it has lost one of its children. Group Minus One Second Fibonacci Heap

  26. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Decrease Key with Marks Case 1: no violation of heap property, finish. Group Minus One Second Fibonacci Heap

  27. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Decrease Key with Marks Case 2: simply remove the subtree and mark the parent node. Group Minus One Second Fibonacci Heap

  28. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Decrease Key with Marks Case 2: simply remove the subtree and mark the parent node. Group Minus One Second Fibonacci Heap

  29. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Decrease Key with Marks Case 2: simply remove the subtree and mark the parent node. Group Minus One Second Fibonacci Heap

  30. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Decrease Key with Marks Case 3: recursively remove all subtrees whose parent is marked. Group Minus One Second Fibonacci Heap

  31. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Decrease Key with Marks Case 3: recursively remove all subtrees whose parent is marked. Group Minus One Second Fibonacci Heap

  32. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Decrease Key with Marks Case 3: recursively remove all subtrees whose parent is marked. Group Minus One Second Fibonacci Heap

  33. Structure Introduction Rank Fibonacci Heap Insert Time Complexity Analysis Delete Min Decrease Key Decrease Key with Marks Case 3: recursively remove all subtrees whose parent is marked. Group Minus One Second Fibonacci Heap

Recommend


More recommend