SlideShare una empresa de Scribd logo
1 de 73
CSN2501 DSA Presentation
              Fibonacci Heap



              Anshuman Biswal
       PT 2012 Batch, Reg. No.: CJB0412001
M. Sc. (Engg.) in Computer Science and Networking




   Module Leader:   N. D. Gangadhar
   Module Name:     Data Structures and Algorithms
   Module Code :    CSN2501

              M. S. Ramaiah School of Advanced Studies   1
Marking

           Head                           Maximum             Score

Technical Content                                10

Grasp and Understanding                          10

Delivery – Technical and                         10
General Aspects
Handling Questions                               10

           Total                                 40


                   M. S. Ramaiah School of Advanced Studies           2
Presentation Outline
•   Introduction
•   Fibonacci Heap Structure
•   Fibonacci Heap Implementation
•   Notations and Potential Function
•   Fibonacci Heap Operations
     –   Make a Fibonacci heap
     –   Insert a node
     –   Find minimum
     –   Bounding the maximum degree and Linking operation
     –   Extract min
     –   Union
     –   Decrease key
     –   Delete key
•   Analysis
•   Fibonacci Heap Bounding the Rank
•   Conclusion
•   References

                             M. S. Ramaiah School of Advanced Studies   3
Introduction
•   Fibonacci heap is a heap data structure consisting of collection of trees.
•   It has a better amortized running time of binomial heap.
•   Developed by Michael L Fredman and Robert E Tarjan in 1984 and
    first published in the scientific journal in 1987.
•   The name Fibonacci heap comes from the Fibonacci numbers which
    are used in running time analysis.
•   Fibo heaps are mostly used when the number of EXTRACT-
    MIN and DELETE operations is small relative to the number of other
    operations performed.
•   Fibonacci heaps are loosely based on Binomial Heaps but have less
    rigid structure.
•   Fibonacci heaps are not good to use for operation Search.
•   Original motivation: improve Dijkstra's shortest path algorithm
    from O(E log V ) to O(E + V log V ). V insert, V delete-min, E decrease-key



                           M. S. Ramaiah School of Advanced Studies               4
Introduction
•   Binomial heap: eagerly consolidate trees after each insert.




•   Fibonacci heap: lazily defer consolidation until next delete-min.

•   It also used for faster method for computing minimum spanning trees
    with improvements from O(m log log base (m/n+2) of n) to
    O(mβ)(m, n), where β(m, n) = min{i | log to the power i of n <= m/n}.




                          M. S. Ramaiah School of Advanced Studies          5
Fibonacci Heap- Structure
•   Fibonacci heap.            each parent larger than its children
     – Set of heap-ordered trees.
     – Maintain pointer to minimum element.
     – Set of marked nodes.


                         roots                                       heap-ordered tree



    17              24           23          7                             3



    30        26    46
                                                                18         52      41


              35
                                                                39                 44
     Heap H

                             M. S. Ramaiah School of Advanced Studies                    6
Fibonacci Heap- Structure
•   Fibonacci heap.
     – Set of heap-ordered trees.
     – Maintain pointer to minimum element.
     – Set of marked nodes.     find-min takes O(1) time




                                                                      min


    17              24       23            7                          3



    30        26    46
                                                              18      52    41


              35
                                                              39            44
     Heap H

                           M. S. Ramaiah School of Advanced Studies              7
Fibonacci Heap- Structure
•   Fibonacci heap.
     – Set of heap-ordered trees.
     – Maintain pointer to minimum element.
     – Set of marked nodes.
                    use to keep heaps flat



                                                                         min


    17              24          23            7                          3



    30        26    46
                                                                 18      52    41

                                                  marked
              35
                                                                 39            44
     Heap H

                              M. S. Ramaiah School of Advanced Studies              8
Fibonacci Heap- Implementation
– Represent trees using left-child, right sibling pointers and circular, doubly
  linked list.
    • Given two such lists ,we can quickly splice off sub trees or concatenate
      in O(1) time
    • Can remove or insert a node in O(1) time
– Roots of trees connected with circular doubly linked list.
    • fast union
– Pointer to root of tree with min element.
                                                              min
    • fast find-min

   17           24         23            7                          3



   30     26    46
                                                            18      52   41


Heap H    35
                                                            39           44


                         M. S. Ramaiah School of Advanced Studies                 9
Fibonacci Heap- Implementation
•   Each node x has pointer p[x] to its parent & child [x] to one of its children
•   Children are linked together in a doubly-linked circular list which is called the
    child list of x.
•   Each child y in a child list has pointers left[y] and right [y] which points to left
    and right siblings.
•   Left[y]==right[y]==y, then y is the only child
•   Each node also has degree [x] indicating the number of children of x
                                                                     min


        17            24         23            7                          3



        30      26    46
                                                                  18      52   41


    Heap H      35
                                                                  39           44




                               M. S. Ramaiah School of Advanced Studies                    10
Fibonacci Heap- Implementation
•   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
•   Some nodes will be marked
    (indicated by the marked bit set to 1).
    (i) A node x will be marked if x has lost a child since the last time that x was
    made a child of another node.
    (ii) Newly created nodes are unmarked
    (iii) When node x becomes child of another node it becomes unmarked

                                                                         3    min = 3
        17            24        23            7


        30      26    46
                                                                 18      52   41


    Heap H      35
                                                                 39           44




                              M. S. Ramaiah School of Advanced Studies                  11
Fibonacci Heap- Implementation
•The entire heap is accessed by a pointer min [H] which points to the minimum-
key root
•Min(H) = NIL => H is empty




                                                                       min


        17           24       23            7                          3



        30     26    46
                                                               18      52    41


    Heap H     35
                                                               39            44




                            M. S. Ramaiah School of Advanced Studies              12
Notation and Potential Function
 Notation
 – n        = number of nodes in heap.
 – rank(x) = number of children of node x.
 – rank(H) = max rank of any node in heap H.
 – trees(H) = number of trees in heap H.
 – marks(H) = number of marked nodes in heap H.
                                                                   min
trees(H) = 5   marks(H) = 3    n = 14                 rank = 3
17             24         23            7                          3



30        26   46
                                                           18      52    41

                                            marked
          35
                                                           39            44
 Heap H

                        M. S. Ramaiah School of Advanced Studies              13
Notation and Potential Function
  Potential Function

       (H) = trees(H) + 2  marks(H)

potential of heap H


 trees(H) = 5         marks(H)=3        Ф (H) = 5 + 2.3 = 11
                                                                       min


  17              24          23            7                          3



  30       26     46
                                                               18      52    41

                                                marked
           35
                                                               39            44
  Heap H

                            M. S. Ramaiah School of Advanced Studies              14
Fibonacci Heap Operations
•   MAKE-FIB-HEAP(): creates and returns a new empty heap.
•   FIB-HEAP-INSERT(H; x): inserts node x, whose key field has
    already been filled in, into heap H.
•   FIB-HEAP-MINIMUM(H): returns a pointer to the node with
    minimum key in heap H.
•   FIB-HEAP-EXTRACT-MIN(H): deletes the node from heap H
    whose key is minimum, returning a pointer to the node.
•   UNION(H1;H2): creates and returns a new heap that contains all
    the nodes of heaps H1 and H2. Heaps H1 and H2 are “destroyed” by
    this operation.
•   FIB-HEAP-DECREASE-KEY(H; x; k) :assigns to node x within
    heap H the new key value k. It is assumed that key ≤ x:key.
•   FIB-HEAP-DELETE(H; x) :deletes node x from heap H.




                        M. S. Ramaiah School of Advanced Studies       15
Fibonacci Heap Operations
Creating a Heap
MAKE-FIB-HEAP():

•   allocates and returns the Fibonacci heap object H with H.n = 0 and
    H.min = NIL:
•   There are no trees in H. (H) = 0
•   Because t(H) = 0 and m(H) = 0, the potential of the empty Fibonacci
    heap  (H) = 0
•   For MAKE-FIB-HEAP: amortized cost = actual cost = O(1).




                         M. S. Ramaiah School of Advanced Studies         16
Fibonacci Heap Operations
Inserting a node
FIB-HEAP-INSERT(H; x):
    – Create a new singleton tree.
    – Add to root list.
    – Update min pointer.


                          21           Insert 21
                                                                   min
  17           24       23             7                            3


  30     26    46
                                                         18        52    41

         35
                                                         39              44

                        M. S. Ramaiah School of Advanced Studies              17
Fibonacci Heap Operations
FIB-HEAP-INSERT Analysis:
Let H = Input Fibonacci heap and H = Resulting Fibonacci heap.
Then t(H) = t(H) + 1 and m(H) = m(H)
 Increase in potential = ((t(H)+1 )+ 2m(H)) - (t(H) + 2m(H)) = 1
Since actual cost = O(1) ,so the amortized cost is O(1) + 1 = O(1)




                                                                   min
  17           24        23            7             21             3


  30     26    46
                                                          18       52    41

         35
                                                          39             44

                        M. S. Ramaiah School of Advanced Studies              18
Fibonacci Heap Operations
Finding the minimum node
FIB-HEAP-MINIMUM(H):
The minimum node of Fibonacci heap is given by the pointer H.min, so
   we can find the minimum node in O(1) actual time.

Since the potential of H does not change, the amortized cost of the
   operation is O(1)




                         M. S. Ramaiah School of Advanced Studies      19
Bounding the maximum degree

If all trees in the Fibonacci heap are unordered
   binomial trees, then D(n) = log 2 n .But the
   (cascading) cuts may cause the occurrence of trees
   that are not unordered binomial. Therefore, a
   slightly weaker result still holds: D(n) ≤ log  n
   where  is the golden ratio and is defined as
   (1+ 5) / 2 = 1.61803




                  M. S. Ramaiah School of Advanced Studies   20
Fibonacci Heap Operations
•    Linking operation. Make larger root be a child of smaller root.




            larger root             smaller root                            still heap-ordered

           15                   3                                                     3



56         24             18    52       41                           15   18        52   41


77                        39             44                  56       24   39             44


 tree T1                       tree T2
                                                             77
                                                                                tree T'


                                M. S. Ramaiah School of Advanced Studies                       21
Fibonacci Heap Operations
•   FIB-HEAP-EXTRACT-MIN makes a root out of each of the
    minimum node-s children and removes the minimum node from the
    root list.
•   Next, it consolidates the root list by linking roots of equal degree until
    at most one root remains of each degree.
•   Consolidate(H) consolidates the root list of H by executing repeatedly
    the following steps until every root in the root list has a distinct degree
    value:
     – Find two roots x and y from the root list with the same degree, and
          with x->key y->key:
     – Link y to x: remove y from the root list , and make y a child of x.
         This operation is performed by FIB-HEAP-LINK.
•   Consolidate(H) uses an auxiliary array A[0::D(H:n)]; if A[i] = y then
    y is currently a root with y->degree = i:



                           M. S. Ramaiah School of Advanced Studies               22
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H):
This is the operation where all work delayed by other operations is done.
delayed work = consolidation (or merging) of the trees in the root list.
    – Extract min and concatenate its children into root list.
    – Consolidate trees so that no two roots have same degree.


                                                                    min


   17              24      23            7                          3



   30        26    46
                                                            18      52    41


             35
                                                            39            44
    Heap H

                         M. S. Ramaiah School of Advanced Studies              23
Fibonacci Heap Operations
             FIB-HEAP-EXTRACT-MIN(H):

             – Extract min and concatenate its children into root list.
             – Consolidate trees so that no two roots have same degree.



      current
min
         7             24           23              17              18      52   41



        30        26   46                                           39           44



                  35


                                 M. S. Ramaiah School of Advanced Studies             24
Fibonacci Heap Operations
             FIB-HEAP-EXTRACT-MIN(H):
             – Delete min and concatenate its children into root list.
             – Consolidate trees so that no two roots have same degree.

                                         0   1   2   3



      current
min
         7             24           23               17             18      52   41



        30        26   46                                           39           44



                  35


                                 M. S. Ramaiah School of Advanced Studies             25
Fibonacci Heap Operations
           FIB-HEAP-EXTRACT-MIN(H):
           – Delete min and concatenate its children into root list.
           – Consolidate trees so that no two roots have same degree.

                                       0   1   2   3

                     current
min
      7                24         23               17             18      52   41



      30        26     46                                         39           44



                35


                               M. S. Ramaiah School of Advanced Studies             26
Fibonacci Heap Operations
           FIB-HEAP-EXTRACT-MIN(H):
           – Delete min and concatenate its children into root list.
           – Consolidate trees so that no two roots have same degree.

                                       0   1   2   3




min
      7              24           23               17             18      52   41



      30        26   46                                           39           44
                              current

                35


                               M. S. Ramaiah School of Advanced Studies             27
Fibonacci Heap Operations
           FIB-HEAP-EXTRACT-MIN(H):
           – Delete min and concatenate its children into root list.
           – Consolidate trees so that no two roots have same degree.

                                       0   1   2   3




min
      7              24           23               17             18      52     41



      30        26   46                                           39             44
                                               current

                35
                                                        Merge 17 and 23 trees.
                               M. S. Ramaiah School of Advanced Studies               28
Fibonacci Heap Operations
           FIB-HEAP-EXTRACT-MIN(H):
           – Delete min and concatenate its children into root list.
           – Consolidate trees so that no two roots have same degree.

                                      0   1    2   3



                                                        current
min
      7              24                            17             18      52    41



      30        26   46                            23             39            44



                35
                                                        Merge 7 and 17 trees.
                               M. S. Ramaiah School of Advanced Studies              29
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H):
– Delete min and concatenate its children into root list.
– Consolidate trees so that no two roots have same degree.

                           0   1    2   3



                               min           current

          24                            7              18      52    41



     26   46                   17       30             39            44



     35                        23
                                             Merge 7 and 24 trees.
                    M. S. Ramaiah School of Advanced Studies              30
Fibonacci Heap Operations

FIB-HEAP-EXTRACT-MIN(H):
– Delete min and concatenate its children into root list.
– Consolidate trees so that no two roots have same degree.
                           0   1    2   3



                               min           current

                                        7              18      52   41



                     24        17       30             39           44



               26    46        23


               35

                    M. S. Ramaiah School of Advanced Studies             31
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H):
– Delete min and concatenate its children into root list.
– Consolidate trees so that no two roots have same degree.
                           0   1    2   3



                               min                current

                                        7              18      52   41



                     24        17       30             39           44



               26    46        23


               35

                    M. S. Ramaiah School of Advanced Studies             32
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H):
– Delete min and concatenate its children into root list.
– Consolidate trees so that no two roots have same degree.
                           0   1    2   3



                               min                             current

                                        7              18        52      41



                     24        17       30             39                44



               26    46        23


               35


                    M. S. Ramaiah School of Advanced Studies                  33
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H):
– Delete min and concatenate its children into root list.
– Consolidate trees so that no two roots have same degree.
                           0   1    2   3



                               min                                    current

                                        7              18      52       41



                     24        17       30             39               44



               26    46        23
                                             Merge 41 and 18 trees.
               35

                    M. S. Ramaiah School of Advanced Studies                    34
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H):
– Delete min and concatenate its children into root list.
– Consolidate trees so that no two roots have same degree.
                           0   1    2   3



                               min                                       current

                                        7                      52          18



                     24        17       30                          41     39



               26    46        23                                   44


               35

                    M. S. Ramaiah School of Advanced Studies                    35
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H):
– Delete min and concatenate its children into root list.
– Consolidate trees so that no two roots have same degree.
                           0   1    2   3



                               min                                       current

                                        7                      52          18



                     24        17       30                          41     39



               26    46        23                                   44


               35


                    M. S. Ramaiah School of Advanced Studies                    36
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H):
– Delete min and concatenate its children into root list.
– Consolidate trees so that no two roots have same degree.


                              min

                                        7                      52        18



                     24       17       30                           41   39



               26    46       23                                    44
                                              Stop.
               35


                    M. S. Ramaiah School of Advanced Studies                  37
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H): Example 2 [1]




                              min


23      7       21              3                     17             24


                                                      30        26   46
                     18        52        38


                                                                35
                     39                  41




                     M. S. Ramaiah School of Advanced Studies             38
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H): Example 2 [1]




23      7       21    18      52         38           17             24



                      39                 41           30        26   46


                                                                35




                     M. S. Ramaiah School of Advanced Studies             39
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H): Example 2 [1]



                 0   1        2   3




                                                           x
23      7       21       18           52   38         17             24



                         39                41         30        26   46


                                                                35




                     M. S. Ramaiah School of Advanced Studies             40
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H): Example 2 [1]



                 0   1        2   3




                                                                          x
23      7       21       18           52   38         17             24



                         39                41         30        26   46


                                                                35




                     M. S. Ramaiah School of Advanced Studies                 41
Fibonacci Heap Operations
    FIB-HEAP-EXTRACT-MIN(H): Example 2 [1]



                     0   1        2   3




x
    23      7       21       18           52   38         17             24



                             39                41         30        26   46


                                                                    35




                         M. S. Ramaiah School of Advanced Studies             42
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H): Example 2 [1]



                     0    1        2   3




     x
23       7          21        18           52   38         17             24



                              39                41         30        26   46


                                                                     35

             Merge 7,23

                          M. S. Ramaiah School of Advanced Studies             43
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H): Example 2 [1]



                     0    1        2   3




     x
         7          21        18           52   38         17             24



                              39                41         30        26   46
         23

                                                                     35

             Merge 7,17

                          M. S. Ramaiah School of Advanced Studies             44
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H): Example 2 [1]



                       0   1        2   3




     x
          7           21       18           52   38                        24


     17
                               39                41                   26   46
                 23

     30                                                               35

              Merge 7,24

                           M. S. Ramaiah School of Advanced Studies             45
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H): Example 2 [1]
                        0   1   2    3




                                         x
        7                                     21      18      52           38


   17
                                                      39                   41
        23         24

   30
             26    46


             35



                                M. S. Ramaiah School of Advanced Studies        46
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H): Example 2 [1]
                        0   1   2    3




                                                           x
        7                                     21      18       52          38


   17
                                                      39                   41
        23         24

   30
             26    46


             35



                                M. S. Ramaiah School of Advanced Studies        47
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H): Example 2 [1]
                        0   1   2    3




                                                                   x
        7                                     21      18      52           38


   17
                                                      39                   41
        23         24

   30
             26    46


             35
                                             Merge 21,52

                                M. S. Ramaiah School of Advanced Studies        48
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H): Example 2 [1]
                        0   1   2    3




                                          x
        7                                     21      18                   38


   17
                                              52      39                   41
        23         24

   30
             26    46


             35
                                              Merge 18,21

                                M. S. Ramaiah School of Advanced Studies        49
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H): Example 2 [1]
                        0   1   2    3




                                                           x
        7                                             18                   38


   17                                    21
                                                      39                   41
        23         24

   30                                    52
             26    46


             35



                                M. S. Ramaiah School of Advanced Studies        50
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN(H): Example 2 [1]
                        0   1   2    3




                                                                                x
        7                                             18                   38


   17                                    21
                                                      39                   41
        23         24

   30                                    52
             26    46


             35
                                                           Stop


                                M. S. Ramaiah School of Advanced Studies            51
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN Analysis
• Notation.
   – D(n) = max degree of any node in Fibonacci heap with n nodes.
   – t(H) = # trees in heap H.
   – (H) = t(H) + 2m(H).
• Actual cost. O(D(n) + t(H))
   – O(D(n)) work adding min's children into root list and updating
     min.
       • at most D(n) children of min node
   – O(D(n) + t(H)) work consolidating trees.
       • work is proportional to size of root list since number of roots
          decreases by one after each merging
       •  D(n) + t(H) - 1 root nodes at beginning of consolidation



                         M. S. Ramaiah School of Advanced Studies          52
Fibonacci Heap Operations
FIB-HEAP-EXTRACT-MIN Analysis
• The potential before extracting the minimum node is t(H) + 2m(H).
• At most D(n) + 1 roots remain and no nodes become marked during
   the operation => the potential after extracting the minimum node is
   ≤(D(n) + 1) + 2m(H).
=> the amortized cost is at most
   P(D(n) + t(H)) + ((D(n) + 1) + 2m(H)) - (t(H) + 2m(H))
   = O(D(n)) + O(t(H)) - t(H)
   = O(D(n))
  because the units of potential can be scaled to dominate the constant
   hidden in O(t(H)):




                         M. S. Ramaiah School of Advanced Studies         53
Fibonacci Heap Operations
FIB-HEAP-UNION(H1,H2)
1. Concatenate the root list of H1 and H2 into new root list H
2. Set the minimum node of H
3. Set n[H] to total number of nodes


                      min                                           min

23             24      17                        7                   3         21


30     26      46
                                                         18         52    41

       35
                                                         39               44

                                                               Heap H2
     Heap H1

                         M. S. Ramaiah School of Advanced Studies                   54
Fibonacci Heap Operations
Analysis: The change in potential is
     Ф(H) - (Ф(H1) + Ф(H2))
    = (t(H) + 2m(H)) - ((t(H1) + 2m(H1)) + ((t(H2) + 2m(H2))
    = 0; ( since, t(H) = t(H1) + t(H2) and m(H) = m(H1) + m(H2)
 => amortized cost of FIB-HEAP-UNION = actual cost = O(1).
                                                                  min

23          24        17                       7                   3         21


30    26    46
                                                       18         52    41

      35
                                                       39               44

                                Heap H


                       M. S. Ramaiah School of Advanced Studies                   55
Fibonacci Heap Operations
•   FIB-HEAP-DECREASE-KEY(H; x; k)
     – Case 1: min-heap property not violated.
        • decrease key of x to k
        • change heap min pointer if necessary

                                                  min
                                          7                          18   38



                               24        17        23        21      39   41



                     26        45
                               46        30                  52



              35     88        72                       Decrease 46 to 45.

                          M. S. Ramaiah School of Advanced Studies             56
Fibonacci Heap Operations
•   FIB-HEAP-DECREASE-KEY(H; x; k)
     – Case 2: parent of x is unmarked.
        • decrease key of x to k
        • cut off link between x and its parent
        • mark parent
        • add tree rooted at x to root list, updating heap min pointer
                                                    min
                                            7                          18   38



                                 24        17        23        21      39   41



                       26        15
                                 45        30                  52



               35      88        72                       Decrease 45 to 15.
                            M. S. Ramaiah School of Advanced Studies             57
Fibonacci Heap Operations
•   FIB-HEAP-DECREASE-KEY(H; x; k)
     – Case 2: parent of x is unmarked.
        • decrease key of x to k
        • cut off link between x and its parent
        • mark parent
        • add tree rooted at x to root list, updating heap min pointer
                                                    min
                                            7                          18   38



                                 24        17        23        21      39   41



                       26        45
                                 15        30                  52



               35      88        72                       Decrease 45 to 15.
                            M. S. Ramaiah School of Advanced Studies             58
Fibonacci Heap Operations
•   FIB-HEAP-DECREASE-KEY(H; x; k)
     – Case 2: parent of x is unmarked.
        • decrease key of x to k
        • cut off link between x and its parent
        • mark parent
        • add tree rooted at x to root list, updating heap min pointer
                                                    min
        15                                  7                          18   38



        72                       24        17        23        21      39   41



                       26                  30                  52



               35      88

                            M. S. Ramaiah School of Advanced Studies             59
Fibonacci Heap Operations
•    FIB-HEAP-DECREASE-KEY(H; x; k)
     – Case 3: parent of x is marked.
        • decrease key of x to k
        • cut off link between x and its parent p[x], and add x to root list
        • cut off link between p[x] and p[p[x]], add p[x] to root list
             – If p[p[x]] unmarked, then mark it.
             – If p[p[x]] marked, cut off p[p[x]], unmark, and repeat
                                                 min
15                                       7                             18      38



72                             24        17       23        21         39      41



                      26                 30                 52



              35
              5       88                               Decrease 35 to 5.
                            M. S. Ramaiah School of Advanced Studies                60
Fibonacci Heap Operations
•    FIB-HEAP-DECREASE-KEY(H; x; k)
     – Case 3: parent of x is marked.
        • decrease key of x to k
        • cut off link between x and its parent p[x], and add x to root list
        • cut off link between p[x] and p[p[x]], add p[x] to root list
             – If p[p[x]] unmarked, then mark it.
             – If p[p[x]] marked, cut off p[p[x]], unmark, and repeat
                                                 min
15           5                           7                             18      38



72                             24        17       23        21         39      41



                      26                 30                 52



                      88                               Decrease 35 to 5.
                            M. S. Ramaiah School of Advanced Studies                61
Fibonacci Heap Operations
•    FIB-HEAP-DECREASE-KEY(H; x; k)
     – Case 3: parent of x is marked.
        • decrease key of x to k
        • cut off link between x and its parent p[x], and add x to root list
        • cut off link between p[x] and p[p[x]], add p[x] to root list
             – If p[p[x]] unmarked, then mark it.
             – If p[p[x]] marked, cut off p[p[x]], unmark, and repeat
                                                 min
15           5        26                 7                             18      38



72                    88       24        17       23        21         39      41



                                         30                 52


                                                       Decrease 35 to 5.
                            M. S. Ramaiah School of Advanced Studies                62
Fibonacci Heap Operations
•    FIB-HEAP-DECREASE-KEY(H; x; k)
     – Case 3: parent of x is marked.
        • decrease key of x to k
        • cut off link between x and its parent p[x], and add x to root list
        • cut off link between p[x] and p[p[x]], add p[x] to root list
             – If p[p[x]] unmarked, then mark it.
             – If p[p[x]] marked, cut off p[p[x]], unmark, and repeat
                                                 min
15           5        26       24        7                             18      38



72                    88                 17       23        21         39      41



                                         30                 52




                            M. S. Ramaiah School of Advanced Studies                63
Fibonacci Heap Operations
FIB-HEAP-DECREASE-KEY(H; x; k) Analysis
• Notation.
   – t(H)        = # trees in heap H.
   – m(H)        = # marked nodes in heap H.
   – (H)        = t(H) + 2m(H).
• Actual cost. O(c)
   – O(1) time for decrease key.
   – O(1) time for each of c cascading cuts, plus reinserting in root list.
• Amortized cost. O(1)
   – t(H')       = t(H) + c
   – m(H')  m(H) - c + 2
       • each cascading cut unmark a node
       • last cascading cut could potentially mark a node
   –   c + 2(-c + 2) = 4 - c.

                          M. S. Ramaiah School of Advanced Studies            64
Fibonacci Heap Operations
FIB-HEAP-DELETE(H; x)
   – Decrease key of x to -.
   – Extract Min or Delete min element in heap.




6        2                         1



         5            3            4                  7


                                                  8


                                             9             Delete 9

                       M. S. Ramaiah School of Advanced Studies       65
Fibonacci Heap Operations
FIB-HEAP-DELETE(H; x)
   – Decrease key of x to -.
   – Extract Min or Delete min element in heap.



                                min

6        2                         1



         5            3            4                  7


                                                  8


                                            -             Delete 9

                       M. S. Ramaiah School of Advanced Studies       66
Fibonacci Heap Operations
FIB-HEAP-DELETE(H; x)
   – Decrease key of x to -.
   – Extract Min or Delete min element in heap.



                                min

6        2                         1                              -



         5            3            4                  7


                                                  8


                                                           Delete 9

                       M. S. Ramaiah School of Advanced Studies        67
Fibonacci Heap Operations
FIB-HEAP-DELETE(H; x)
   – Decrease key of x to -.
   – Extract Min or Delete min element in heap.



                                               min

6        2                         1            -           8        7



         5            3            4




                                                           Delete 9

                       M. S. Ramaiah School of Advanced Studies           68
Fibonacci Heap Operations
FIB-HEAP-DELETE(H; x)
   – Decrease key of x to -.
   – Extract Min or Delete min element in heap.



                                               min

6        2                         1            -           8        7



         5            3            4




                                                           Delete 9

                       M. S. Ramaiah School of Advanced Studies           69
Fibonacci Heap Operations
FIB-HEAP-DELETE(H; x)
   – Decrease key of x to -.
   – Extract Min or Delete min element in heap.


                               min


6                                  1



                  2            3                4


              5       7


                      8                                    Delete 9

                       M. S. Ramaiah School of Advanced Studies       70
Fibonacci Heap Operations
FIB-HEAP-DELETE(H; x) Analysis
• The amortized execution time of FIB-HEAP-DELETE(H; x) is the
   sum of the amortized time of FIB-HEAP-DECREASE i.e. O(1) and
   the amortized time of FIB-HEAP-EXTRACT-MIN(H) i.e. O(D(n))




                      M. S. Ramaiah School of Advanced Studies    71
Conclusion
•   Fibonacci heap is a heap data structure consisting of collection of trees.
•   It has a better amortized running time of binomial heap.
•   It improve Dijkstra's shortest path algorithm
    from O(E log V ) to O(E + V log V ).
•   It is a heap ordered trees with the minimum node pointed to by a
    pointer and some nodes marked.
•   Fibonacci heap takes a amortized time of O(1) for make heap, insert,
    find min ,union , decrease key and is empty operations and a O(log n)
    amortized time for delete-min and delete operation.




                          M. S. Ramaiah School of Advanced Studies               72
References
[1] Cormen T.H, Leiserson C.E., Rivest R.L., and Stein
   C,(2009),IntroductiontoAlgorithms,3rdedn,NewDelhi:
   Prentice Hall of India
[2] Fredman M and Tarjan R.E.,(July 1987), Fibonacci Heaps
   and Their Uses in Improved Network Optimization
   Algorithms. Journal of the Association for Computing
   Machinery, Vol. 34, No. 3, July 1987, Pages 596-615.




                   M. S. Ramaiah School of Advanced Studies   73

Más contenido relacionado

La actualidad más candente

Binomial heap presentation
Binomial heap presentationBinomial heap presentation
Binomial heap presentationHafsa.Naseem
 
Lecture optimal binary search tree
Lecture optimal binary search tree Lecture optimal binary search tree
Lecture optimal binary search tree Divya Ks
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First SearchKevin Jadiya
 
Hashing In Data Structure
Hashing In Data Structure Hashing In Data Structure
Hashing In Data Structure Meghaj Mallick
 
Control Strategies in AI
Control Strategies in AIControl Strategies in AI
Control Strategies in AIAmey Kerkar
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy methodhodcsencet
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithmMohd Arif
 
Dfs presentation
Dfs presentationDfs presentation
Dfs presentationAlizay Khan
 
RABIN KARP ALGORITHM STRING MATCHING
RABIN KARP ALGORITHM STRING MATCHINGRABIN KARP ALGORITHM STRING MATCHING
RABIN KARP ALGORITHM STRING MATCHINGAbhishek Singh
 
Data Structures : hashing (1)
Data Structures : hashing (1)Data Structures : hashing (1)
Data Structures : hashing (1)Home
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemMohammad Imam Hossain
 
Bruteforce algorithm
Bruteforce algorithmBruteforce algorithm
Bruteforce algorithmRezwan Siam
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and boundAbhishek Singh
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplicationRespa Peter
 

La actualidad más candente (20)

Binomial heap presentation
Binomial heap presentationBinomial heap presentation
Binomial heap presentation
 
Lecture optimal binary search tree
Lecture optimal binary search tree Lecture optimal binary search tree
Lecture optimal binary search tree
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
 
Spanning trees
Spanning treesSpanning trees
Spanning trees
 
Hashing In Data Structure
Hashing In Data Structure Hashing In Data Structure
Hashing In Data Structure
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
Control Strategies in AI
Control Strategies in AIControl Strategies in AI
Control Strategies in AI
 
Disjoint sets
Disjoint setsDisjoint sets
Disjoint sets
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
 
Dfs presentation
Dfs presentationDfs presentation
Dfs presentation
 
RABIN KARP ALGORITHM STRING MATCHING
RABIN KARP ALGORITHM STRING MATCHINGRABIN KARP ALGORITHM STRING MATCHING
RABIN KARP ALGORITHM STRING MATCHING
 
Extensible hashing
Extensible hashingExtensible hashing
Extensible hashing
 
Data Structures : hashing (1)
Data Structures : hashing (1)Data Structures : hashing (1)
Data Structures : hashing (1)
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction Problem
 
Bruteforce algorithm
Bruteforce algorithmBruteforce algorithm
Bruteforce algorithm
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and bound
 
Hash table
Hash tableHash table
Hash table
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplication
 

Más de Anshuman Biswal

भक्ति वृक्षा – CHAPTER 1 (1).pptx
भक्ति वृक्षा – CHAPTER 1 (1).pptxभक्ति वृक्षा – CHAPTER 1 (1).pptx
भक्ति वृक्षा – CHAPTER 1 (1).pptxAnshuman Biswal
 
Wireless Networking Security
Wireless Networking SecurityWireless Networking Security
Wireless Networking SecurityAnshuman Biswal
 
Ir da in_linux_presentation
Ir da in_linux_presentationIr da in_linux_presentation
Ir da in_linux_presentationAnshuman Biswal
 
Message Signaled Interrupts
Message Signaled InterruptsMessage Signaled Interrupts
Message Signaled InterruptsAnshuman Biswal
 
Bangalore gayatri pariwar gayatri ashwamedha mahayagya
Bangalore gayatri pariwar gayatri ashwamedha mahayagyaBangalore gayatri pariwar gayatri ashwamedha mahayagya
Bangalore gayatri pariwar gayatri ashwamedha mahayagyaAnshuman Biswal
 
Six Sigma and/For Software Engineering
Six Sigma and/For Software EngineeringSix Sigma and/For Software Engineering
Six Sigma and/For Software EngineeringAnshuman Biswal
 
Fast web development using groovy on grails
Fast web development using groovy on grailsFast web development using groovy on grails
Fast web development using groovy on grailsAnshuman Biswal
 

Más de Anshuman Biswal (13)

भक्ति वृक्षा – CHAPTER 1 (1).pptx
भक्ति वृक्षा – CHAPTER 1 (1).pptxभक्ति वृक्षा – CHAPTER 1 (1).pptx
भक्ति वृक्षा – CHAPTER 1 (1).pptx
 
Wireless Networking Security
Wireless Networking SecurityWireless Networking Security
Wireless Networking Security
 
Pervasive Computing
Pervasive ComputingPervasive Computing
Pervasive Computing
 
Observer Pattern
Observer PatternObserver Pattern
Observer Pattern
 
Undecidabality
UndecidabalityUndecidabality
Undecidabality
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Ir da in_linux_presentation
Ir da in_linux_presentationIr da in_linux_presentation
Ir da in_linux_presentation
 
Message Signaled Interrupts
Message Signaled InterruptsMessage Signaled Interrupts
Message Signaled Interrupts
 
Array Processor
Array ProcessorArray Processor
Array Processor
 
Bangalore gayatri pariwar gayatri ashwamedha mahayagya
Bangalore gayatri pariwar gayatri ashwamedha mahayagyaBangalore gayatri pariwar gayatri ashwamedha mahayagya
Bangalore gayatri pariwar gayatri ashwamedha mahayagya
 
Six Sigma and/For Software Engineering
Six Sigma and/For Software EngineeringSix Sigma and/For Software Engineering
Six Sigma and/For Software Engineering
 
SNMP
SNMPSNMP
SNMP
 
Fast web development using groovy on grails
Fast web development using groovy on grailsFast web development using groovy on grails
Fast web development using groovy on grails
 

Último

Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxAmita Gupta
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 

Último (20)

Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 

Fibonacci Heap

  • 1. CSN2501 DSA Presentation Fibonacci Heap Anshuman Biswal PT 2012 Batch, Reg. No.: CJB0412001 M. Sc. (Engg.) in Computer Science and Networking Module Leader: N. D. Gangadhar Module Name: Data Structures and Algorithms Module Code : CSN2501 M. S. Ramaiah School of Advanced Studies 1
  • 2. Marking Head Maximum Score Technical Content 10 Grasp and Understanding 10 Delivery – Technical and 10 General Aspects Handling Questions 10 Total 40 M. S. Ramaiah School of Advanced Studies 2
  • 3. Presentation Outline • Introduction • Fibonacci Heap Structure • Fibonacci Heap Implementation • Notations and Potential Function • Fibonacci Heap Operations – Make a Fibonacci heap – Insert a node – Find minimum – Bounding the maximum degree and Linking operation – Extract min – Union – Decrease key – Delete key • Analysis • Fibonacci Heap Bounding the Rank • Conclusion • References M. S. Ramaiah School of Advanced Studies 3
  • 4. Introduction • Fibonacci heap is a heap data structure consisting of collection of trees. • It has a better amortized running time of binomial heap. • Developed by Michael L Fredman and Robert E Tarjan in 1984 and first published in the scientific journal in 1987. • The name Fibonacci heap comes from the Fibonacci numbers which are used in running time analysis. • Fibo heaps are mostly used when the number of EXTRACT- MIN and DELETE operations is small relative to the number of other operations performed. • Fibonacci heaps are loosely based on Binomial Heaps but have less rigid structure. • Fibonacci heaps are not good to use for operation Search. • Original motivation: improve Dijkstra's shortest path algorithm from O(E log V ) to O(E + V log V ). V insert, V delete-min, E decrease-key M. S. Ramaiah School of Advanced Studies 4
  • 5. Introduction • Binomial heap: eagerly consolidate trees after each insert. • Fibonacci heap: lazily defer consolidation until next delete-min. • It also used for faster method for computing minimum spanning trees with improvements from O(m log log base (m/n+2) of n) to O(mβ)(m, n), where β(m, n) = min{i | log to the power i of n <= m/n}. M. S. Ramaiah School of Advanced Studies 5
  • 6. Fibonacci Heap- Structure • Fibonacci heap. each parent larger than its children – Set of heap-ordered trees. – Maintain pointer to minimum element. – Set of marked nodes. roots heap-ordered tree 17 24 23 7 3 30 26 46 18 52 41 35 39 44 Heap H M. S. Ramaiah School of Advanced Studies 6
  • 7. Fibonacci Heap- Structure • Fibonacci heap. – Set of heap-ordered trees. – Maintain pointer to minimum element. – Set of marked nodes. find-min takes O(1) time min 17 24 23 7 3 30 26 46 18 52 41 35 39 44 Heap H M. S. Ramaiah School of Advanced Studies 7
  • 8. Fibonacci Heap- Structure • Fibonacci heap. – Set of heap-ordered trees. – Maintain pointer to minimum element. – Set of marked nodes. use to keep heaps flat min 17 24 23 7 3 30 26 46 18 52 41 marked 35 39 44 Heap H M. S. Ramaiah School of Advanced Studies 8
  • 9. Fibonacci Heap- Implementation – Represent trees using left-child, right sibling pointers and circular, doubly linked list. • Given two such lists ,we can quickly splice off sub trees or concatenate in O(1) time • Can remove or insert a node in O(1) time – Roots of trees connected with circular doubly linked list. • fast union – Pointer to root of tree with min element. min • fast find-min 17 24 23 7 3 30 26 46 18 52 41 Heap H 35 39 44 M. S. Ramaiah School of Advanced Studies 9
  • 10. Fibonacci Heap- Implementation • Each node x has pointer p[x] to its parent & child [x] to one of its children • Children are linked together in a doubly-linked circular list which is called the child list of x. • Each child y in a child list has pointers left[y] and right [y] which points to left and right siblings. • Left[y]==right[y]==y, then y is the only child • Each node also has degree [x] indicating the number of children of x min 17 24 23 7 3 30 26 46 18 52 41 Heap H 35 39 44 M. S. Ramaiah School of Advanced Studies 10
  • 11. Fibonacci Heap- Implementation • 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 • Some nodes will be marked (indicated by the marked bit set to 1). (i) A node x will be marked if x has lost a child since the last time that x was made a child of another node. (ii) Newly created nodes are unmarked (iii) When node x becomes child of another node it becomes unmarked 3 min = 3 17 24 23 7 30 26 46 18 52 41 Heap H 35 39 44 M. S. Ramaiah School of Advanced Studies 11
  • 12. Fibonacci Heap- Implementation •The entire heap is accessed by a pointer min [H] which points to the minimum- key root •Min(H) = NIL => H is empty min 17 24 23 7 3 30 26 46 18 52 41 Heap H 35 39 44 M. S. Ramaiah School of Advanced Studies 12
  • 13. Notation and Potential Function Notation – n = number of nodes in heap. – rank(x) = number of children of node x. – rank(H) = max rank of any node in heap H. – trees(H) = number of trees in heap H. – marks(H) = number of marked nodes in heap H. min trees(H) = 5 marks(H) = 3 n = 14 rank = 3 17 24 23 7 3 30 26 46 18 52 41 marked 35 39 44 Heap H M. S. Ramaiah School of Advanced Studies 13
  • 14. Notation and Potential Function Potential Function (H) = trees(H) + 2  marks(H) potential of heap H trees(H) = 5 marks(H)=3 Ф (H) = 5 + 2.3 = 11 min 17 24 23 7 3 30 26 46 18 52 41 marked 35 39 44 Heap H M. S. Ramaiah School of Advanced Studies 14
  • 15. Fibonacci Heap Operations • MAKE-FIB-HEAP(): creates and returns a new empty heap. • FIB-HEAP-INSERT(H; x): inserts node x, whose key field has already been filled in, into heap H. • FIB-HEAP-MINIMUM(H): returns a pointer to the node with minimum key in heap H. • FIB-HEAP-EXTRACT-MIN(H): deletes the node from heap H whose key is minimum, returning a pointer to the node. • UNION(H1;H2): creates and returns a new heap that contains all the nodes of heaps H1 and H2. Heaps H1 and H2 are “destroyed” by this operation. • FIB-HEAP-DECREASE-KEY(H; x; k) :assigns to node x within heap H the new key value k. It is assumed that key ≤ x:key. • FIB-HEAP-DELETE(H; x) :deletes node x from heap H. M. S. Ramaiah School of Advanced Studies 15
  • 16. Fibonacci Heap Operations Creating a Heap MAKE-FIB-HEAP(): • allocates and returns the Fibonacci heap object H with H.n = 0 and H.min = NIL: • There are no trees in H. (H) = 0 • Because t(H) = 0 and m(H) = 0, the potential of the empty Fibonacci heap  (H) = 0 • For MAKE-FIB-HEAP: amortized cost = actual cost = O(1). M. S. Ramaiah School of Advanced Studies 16
  • 17. Fibonacci Heap Operations Inserting a node FIB-HEAP-INSERT(H; x): – Create a new singleton tree. – Add to root list. – Update min pointer. 21 Insert 21 min 17 24 23 7 3 30 26 46 18 52 41 35 39 44 M. S. Ramaiah School of Advanced Studies 17
  • 18. Fibonacci Heap Operations FIB-HEAP-INSERT Analysis: Let H = Input Fibonacci heap and H = Resulting Fibonacci heap. Then t(H) = t(H) + 1 and m(H) = m(H)  Increase in potential = ((t(H)+1 )+ 2m(H)) - (t(H) + 2m(H)) = 1 Since actual cost = O(1) ,so the amortized cost is O(1) + 1 = O(1) min 17 24 23 7 21 3 30 26 46 18 52 41 35 39 44 M. S. Ramaiah School of Advanced Studies 18
  • 19. Fibonacci Heap Operations Finding the minimum node FIB-HEAP-MINIMUM(H): The minimum node of Fibonacci heap is given by the pointer H.min, so we can find the minimum node in O(1) actual time. Since the potential of H does not change, the amortized cost of the operation is O(1) M. S. Ramaiah School of Advanced Studies 19
  • 20. Bounding the maximum degree If all trees in the Fibonacci heap are unordered binomial trees, then D(n) = log 2 n .But the (cascading) cuts may cause the occurrence of trees that are not unordered binomial. Therefore, a slightly weaker result still holds: D(n) ≤ log  n where  is the golden ratio and is defined as (1+ 5) / 2 = 1.61803 M. S. Ramaiah School of Advanced Studies 20
  • 21. Fibonacci Heap Operations • Linking operation. Make larger root be a child of smaller root. larger root smaller root still heap-ordered 15 3 3 56 24 18 52 41 15 18 52 41 77 39 44 56 24 39 44 tree T1 tree T2 77 tree T' M. S. Ramaiah School of Advanced Studies 21
  • 22. Fibonacci Heap Operations • FIB-HEAP-EXTRACT-MIN makes a root out of each of the minimum node-s children and removes the minimum node from the root list. • Next, it consolidates the root list by linking roots of equal degree until at most one root remains of each degree. • Consolidate(H) consolidates the root list of H by executing repeatedly the following steps until every root in the root list has a distinct degree value: – Find two roots x and y from the root list with the same degree, and with x->key y->key: – Link y to x: remove y from the root list , and make y a child of x. This operation is performed by FIB-HEAP-LINK. • Consolidate(H) uses an auxiliary array A[0::D(H:n)]; if A[i] = y then y is currently a root with y->degree = i: M. S. Ramaiah School of Advanced Studies 22
  • 23. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): This is the operation where all work delayed by other operations is done. delayed work = consolidation (or merging) of the trees in the root list. – Extract min and concatenate its children into root list. – Consolidate trees so that no two roots have same degree. min 17 24 23 7 3 30 26 46 18 52 41 35 39 44 Heap H M. S. Ramaiah School of Advanced Studies 23
  • 24. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): – Extract min and concatenate its children into root list. – Consolidate trees so that no two roots have same degree. current min 7 24 23 17 18 52 41 30 26 46 39 44 35 M. S. Ramaiah School of Advanced Studies 24
  • 25. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): – Delete min and concatenate its children into root list. – Consolidate trees so that no two roots have same degree. 0 1 2 3 current min 7 24 23 17 18 52 41 30 26 46 39 44 35 M. S. Ramaiah School of Advanced Studies 25
  • 26. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): – Delete min and concatenate its children into root list. – Consolidate trees so that no two roots have same degree. 0 1 2 3 current min 7 24 23 17 18 52 41 30 26 46 39 44 35 M. S. Ramaiah School of Advanced Studies 26
  • 27. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): – Delete min and concatenate its children into root list. – Consolidate trees so that no two roots have same degree. 0 1 2 3 min 7 24 23 17 18 52 41 30 26 46 39 44 current 35 M. S. Ramaiah School of Advanced Studies 27
  • 28. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): – Delete min and concatenate its children into root list. – Consolidate trees so that no two roots have same degree. 0 1 2 3 min 7 24 23 17 18 52 41 30 26 46 39 44 current 35 Merge 17 and 23 trees. M. S. Ramaiah School of Advanced Studies 28
  • 29. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): – Delete min and concatenate its children into root list. – Consolidate trees so that no two roots have same degree. 0 1 2 3 current min 7 24 17 18 52 41 30 26 46 23 39 44 35 Merge 7 and 17 trees. M. S. Ramaiah School of Advanced Studies 29
  • 30. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): – Delete min and concatenate its children into root list. – Consolidate trees so that no two roots have same degree. 0 1 2 3 min current 24 7 18 52 41 26 46 17 30 39 44 35 23 Merge 7 and 24 trees. M. S. Ramaiah School of Advanced Studies 30
  • 31. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): – Delete min and concatenate its children into root list. – Consolidate trees so that no two roots have same degree. 0 1 2 3 min current 7 18 52 41 24 17 30 39 44 26 46 23 35 M. S. Ramaiah School of Advanced Studies 31
  • 32. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): – Delete min and concatenate its children into root list. – Consolidate trees so that no two roots have same degree. 0 1 2 3 min current 7 18 52 41 24 17 30 39 44 26 46 23 35 M. S. Ramaiah School of Advanced Studies 32
  • 33. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): – Delete min and concatenate its children into root list. – Consolidate trees so that no two roots have same degree. 0 1 2 3 min current 7 18 52 41 24 17 30 39 44 26 46 23 35 M. S. Ramaiah School of Advanced Studies 33
  • 34. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): – Delete min and concatenate its children into root list. – Consolidate trees so that no two roots have same degree. 0 1 2 3 min current 7 18 52 41 24 17 30 39 44 26 46 23 Merge 41 and 18 trees. 35 M. S. Ramaiah School of Advanced Studies 34
  • 35. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): – Delete min and concatenate its children into root list. – Consolidate trees so that no two roots have same degree. 0 1 2 3 min current 7 52 18 24 17 30 41 39 26 46 23 44 35 M. S. Ramaiah School of Advanced Studies 35
  • 36. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): – Delete min and concatenate its children into root list. – Consolidate trees so that no two roots have same degree. 0 1 2 3 min current 7 52 18 24 17 30 41 39 26 46 23 44 35 M. S. Ramaiah School of Advanced Studies 36
  • 37. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): – Delete min and concatenate its children into root list. – Consolidate trees so that no two roots have same degree. min 7 52 18 24 17 30 41 39 26 46 23 44 Stop. 35 M. S. Ramaiah School of Advanced Studies 37
  • 38. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): Example 2 [1] min 23 7 21 3 17 24 30 26 46 18 52 38 35 39 41 M. S. Ramaiah School of Advanced Studies 38
  • 39. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): Example 2 [1] 23 7 21 18 52 38 17 24 39 41 30 26 46 35 M. S. Ramaiah School of Advanced Studies 39
  • 40. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): Example 2 [1] 0 1 2 3 x 23 7 21 18 52 38 17 24 39 41 30 26 46 35 M. S. Ramaiah School of Advanced Studies 40
  • 41. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): Example 2 [1] 0 1 2 3 x 23 7 21 18 52 38 17 24 39 41 30 26 46 35 M. S. Ramaiah School of Advanced Studies 41
  • 42. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): Example 2 [1] 0 1 2 3 x 23 7 21 18 52 38 17 24 39 41 30 26 46 35 M. S. Ramaiah School of Advanced Studies 42
  • 43. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): Example 2 [1] 0 1 2 3 x 23 7 21 18 52 38 17 24 39 41 30 26 46 35 Merge 7,23 M. S. Ramaiah School of Advanced Studies 43
  • 44. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): Example 2 [1] 0 1 2 3 x 7 21 18 52 38 17 24 39 41 30 26 46 23 35 Merge 7,17 M. S. Ramaiah School of Advanced Studies 44
  • 45. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): Example 2 [1] 0 1 2 3 x 7 21 18 52 38 24 17 39 41 26 46 23 30 35 Merge 7,24 M. S. Ramaiah School of Advanced Studies 45
  • 46. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): Example 2 [1] 0 1 2 3 x 7 21 18 52 38 17 39 41 23 24 30 26 46 35 M. S. Ramaiah School of Advanced Studies 46
  • 47. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): Example 2 [1] 0 1 2 3 x 7 21 18 52 38 17 39 41 23 24 30 26 46 35 M. S. Ramaiah School of Advanced Studies 47
  • 48. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): Example 2 [1] 0 1 2 3 x 7 21 18 52 38 17 39 41 23 24 30 26 46 35 Merge 21,52 M. S. Ramaiah School of Advanced Studies 48
  • 49. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): Example 2 [1] 0 1 2 3 x 7 21 18 38 17 52 39 41 23 24 30 26 46 35 Merge 18,21 M. S. Ramaiah School of Advanced Studies 49
  • 50. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): Example 2 [1] 0 1 2 3 x 7 18 38 17 21 39 41 23 24 30 52 26 46 35 M. S. Ramaiah School of Advanced Studies 50
  • 51. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN(H): Example 2 [1] 0 1 2 3 x 7 18 38 17 21 39 41 23 24 30 52 26 46 35 Stop M. S. Ramaiah School of Advanced Studies 51
  • 52. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN Analysis • Notation. – D(n) = max degree of any node in Fibonacci heap with n nodes. – t(H) = # trees in heap H. – (H) = t(H) + 2m(H). • Actual cost. O(D(n) + t(H)) – O(D(n)) work adding min's children into root list and updating min. • at most D(n) children of min node – O(D(n) + t(H)) work consolidating trees. • work is proportional to size of root list since number of roots decreases by one after each merging •  D(n) + t(H) - 1 root nodes at beginning of consolidation M. S. Ramaiah School of Advanced Studies 52
  • 53. Fibonacci Heap Operations FIB-HEAP-EXTRACT-MIN Analysis • The potential before extracting the minimum node is t(H) + 2m(H). • At most D(n) + 1 roots remain and no nodes become marked during the operation => the potential after extracting the minimum node is ≤(D(n) + 1) + 2m(H). => the amortized cost is at most P(D(n) + t(H)) + ((D(n) + 1) + 2m(H)) - (t(H) + 2m(H)) = O(D(n)) + O(t(H)) - t(H) = O(D(n)) because the units of potential can be scaled to dominate the constant hidden in O(t(H)): M. S. Ramaiah School of Advanced Studies 53
  • 54. Fibonacci Heap Operations FIB-HEAP-UNION(H1,H2) 1. Concatenate the root list of H1 and H2 into new root list H 2. Set the minimum node of H 3. Set n[H] to total number of nodes min min 23 24 17 7 3 21 30 26 46 18 52 41 35 39 44 Heap H2 Heap H1 M. S. Ramaiah School of Advanced Studies 54
  • 55. Fibonacci Heap Operations Analysis: The change in potential is Ф(H) - (Ф(H1) + Ф(H2)) = (t(H) + 2m(H)) - ((t(H1) + 2m(H1)) + ((t(H2) + 2m(H2)) = 0; ( since, t(H) = t(H1) + t(H2) and m(H) = m(H1) + m(H2) => amortized cost of FIB-HEAP-UNION = actual cost = O(1). min 23 24 17 7 3 21 30 26 46 18 52 41 35 39 44 Heap H M. S. Ramaiah School of Advanced Studies 55
  • 56. Fibonacci Heap Operations • FIB-HEAP-DECREASE-KEY(H; x; k) – Case 1: min-heap property not violated. • decrease key of x to k • change heap min pointer if necessary min 7 18 38 24 17 23 21 39 41 26 45 46 30 52 35 88 72 Decrease 46 to 45. M. S. Ramaiah School of Advanced Studies 56
  • 57. Fibonacci Heap Operations • FIB-HEAP-DECREASE-KEY(H; x; k) – Case 2: parent of x is unmarked. • decrease key of x to k • cut off link between x and its parent • mark parent • add tree rooted at x to root list, updating heap min pointer min 7 18 38 24 17 23 21 39 41 26 15 45 30 52 35 88 72 Decrease 45 to 15. M. S. Ramaiah School of Advanced Studies 57
  • 58. Fibonacci Heap Operations • FIB-HEAP-DECREASE-KEY(H; x; k) – Case 2: parent of x is unmarked. • decrease key of x to k • cut off link between x and its parent • mark parent • add tree rooted at x to root list, updating heap min pointer min 7 18 38 24 17 23 21 39 41 26 45 15 30 52 35 88 72 Decrease 45 to 15. M. S. Ramaiah School of Advanced Studies 58
  • 59. Fibonacci Heap Operations • FIB-HEAP-DECREASE-KEY(H; x; k) – Case 2: parent of x is unmarked. • decrease key of x to k • cut off link between x and its parent • mark parent • add tree rooted at x to root list, updating heap min pointer min 15 7 18 38 72 24 17 23 21 39 41 26 30 52 35 88 M. S. Ramaiah School of Advanced Studies 59
  • 60. Fibonacci Heap Operations • FIB-HEAP-DECREASE-KEY(H; x; k) – Case 3: parent of x is marked. • decrease key of x to k • cut off link between x and its parent p[x], and add x to root list • cut off link between p[x] and p[p[x]], add p[x] to root list – If p[p[x]] unmarked, then mark it. – If p[p[x]] marked, cut off p[p[x]], unmark, and repeat min 15 7 18 38 72 24 17 23 21 39 41 26 30 52 35 5 88 Decrease 35 to 5. M. S. Ramaiah School of Advanced Studies 60
  • 61. Fibonacci Heap Operations • FIB-HEAP-DECREASE-KEY(H; x; k) – Case 3: parent of x is marked. • decrease key of x to k • cut off link between x and its parent p[x], and add x to root list • cut off link between p[x] and p[p[x]], add p[x] to root list – If p[p[x]] unmarked, then mark it. – If p[p[x]] marked, cut off p[p[x]], unmark, and repeat min 15 5 7 18 38 72 24 17 23 21 39 41 26 30 52 88 Decrease 35 to 5. M. S. Ramaiah School of Advanced Studies 61
  • 62. Fibonacci Heap Operations • FIB-HEAP-DECREASE-KEY(H; x; k) – Case 3: parent of x is marked. • decrease key of x to k • cut off link between x and its parent p[x], and add x to root list • cut off link between p[x] and p[p[x]], add p[x] to root list – If p[p[x]] unmarked, then mark it. – If p[p[x]] marked, cut off p[p[x]], unmark, and repeat min 15 5 26 7 18 38 72 88 24 17 23 21 39 41 30 52 Decrease 35 to 5. M. S. Ramaiah School of Advanced Studies 62
  • 63. Fibonacci Heap Operations • FIB-HEAP-DECREASE-KEY(H; x; k) – Case 3: parent of x is marked. • decrease key of x to k • cut off link between x and its parent p[x], and add x to root list • cut off link between p[x] and p[p[x]], add p[x] to root list – If p[p[x]] unmarked, then mark it. – If p[p[x]] marked, cut off p[p[x]], unmark, and repeat min 15 5 26 24 7 18 38 72 88 17 23 21 39 41 30 52 M. S. Ramaiah School of Advanced Studies 63
  • 64. Fibonacci Heap Operations FIB-HEAP-DECREASE-KEY(H; x; k) Analysis • Notation. – t(H) = # trees in heap H. – m(H) = # marked nodes in heap H. – (H) = t(H) + 2m(H). • Actual cost. O(c) – O(1) time for decrease key. – O(1) time for each of c cascading cuts, plus reinserting in root list. • Amortized cost. O(1) – t(H') = t(H) + c – m(H')  m(H) - c + 2 • each cascading cut unmark a node • last cascading cut could potentially mark a node –   c + 2(-c + 2) = 4 - c. M. S. Ramaiah School of Advanced Studies 64
  • 65. Fibonacci Heap Operations FIB-HEAP-DELETE(H; x) – Decrease key of x to -. – Extract Min or Delete min element in heap. 6 2 1 5 3 4 7 8 9 Delete 9 M. S. Ramaiah School of Advanced Studies 65
  • 66. Fibonacci Heap Operations FIB-HEAP-DELETE(H; x) – Decrease key of x to -. – Extract Min or Delete min element in heap. min 6 2 1 5 3 4 7 8 - Delete 9 M. S. Ramaiah School of Advanced Studies 66
  • 67. Fibonacci Heap Operations FIB-HEAP-DELETE(H; x) – Decrease key of x to -. – Extract Min or Delete min element in heap. min 6 2 1 - 5 3 4 7 8 Delete 9 M. S. Ramaiah School of Advanced Studies 67
  • 68. Fibonacci Heap Operations FIB-HEAP-DELETE(H; x) – Decrease key of x to -. – Extract Min or Delete min element in heap. min 6 2 1 - 8 7 5 3 4 Delete 9 M. S. Ramaiah School of Advanced Studies 68
  • 69. Fibonacci Heap Operations FIB-HEAP-DELETE(H; x) – Decrease key of x to -. – Extract Min or Delete min element in heap. min 6 2 1 - 8 7 5 3 4 Delete 9 M. S. Ramaiah School of Advanced Studies 69
  • 70. Fibonacci Heap Operations FIB-HEAP-DELETE(H; x) – Decrease key of x to -. – Extract Min or Delete min element in heap. min 6 1 2 3 4 5 7 8 Delete 9 M. S. Ramaiah School of Advanced Studies 70
  • 71. Fibonacci Heap Operations FIB-HEAP-DELETE(H; x) Analysis • The amortized execution time of FIB-HEAP-DELETE(H; x) is the sum of the amortized time of FIB-HEAP-DECREASE i.e. O(1) and the amortized time of FIB-HEAP-EXTRACT-MIN(H) i.e. O(D(n)) M. S. Ramaiah School of Advanced Studies 71
  • 72. Conclusion • Fibonacci heap is a heap data structure consisting of collection of trees. • It has a better amortized running time of binomial heap. • It improve Dijkstra's shortest path algorithm from O(E log V ) to O(E + V log V ). • It is a heap ordered trees with the minimum node pointed to by a pointer and some nodes marked. • Fibonacci heap takes a amortized time of O(1) for make heap, insert, find min ,union , decrease key and is empty operations and a O(log n) amortized time for delete-min and delete operation. M. S. Ramaiah School of Advanced Studies 72
  • 73. References [1] Cormen T.H, Leiserson C.E., Rivest R.L., and Stein C,(2009),IntroductiontoAlgorithms,3rdedn,NewDelhi: Prentice Hall of India [2] Fredman M and Tarjan R.E.,(July 1987), Fibonacci Heaps and Their Uses in Improved Network Optimization Algorithms. Journal of the Association for Computing Machinery, Vol. 34, No. 3, July 1987, Pages 596-615. M. S. Ramaiah School of Advanced Studies 73