Skip to main content

Bounding Rank of Fibonacci Heap

Bounding Rank of Fibonacci Heap to lgn:
Before understanding the concept see below notations,
  1. tree(H)=number of nodes in the root list in below Fibonacci Heap Example
  2. rank(x)=number of children it has
  3. rank(H)=max rank(x) 

Fibonacci_Heap


Note: Black nodes are marked nodes (when one of its children is deleted it is marked if it is not already marked).

We have following operation in Fibonacci Heap:
  1. Insert - O(1)
  2. Union - O(1)
  3. Decrease Key - O(1)
  4. Delete-Min - O(Rank(H)) = O(lgn)
  5. Delete - O(Rank(H)) = O(lgn)
In this blog we will see how the rank is bounded to be lgn.
So some assumptions I have made that you know at a time we cannot delete >1 child of any node.
And after deleting child of a node we make it as Marked Node  if it is not marked already.

Some Background;
Merge Operation: We do merge operation when we do delete minimum. Merge operation is when rank of two nodes is same, we merge them as making minimum of them as root node and other as child of it.

Now when do we merge: When rank of two nodes is same we perform the merge operation

Let's say there is node xi and it has children y1, y2, y3, .....yn, and we are interested in finding the rank of yi


So we say that rank of Rank(yi) >={1.    0 ,   otherwise
                                                           2.    i-2,       i>=2  }
Why do we even say the above statement, read following assertions first:
  1. Node xi can >=i - 1 children as one child can be cut.
  2. Node yi  would have been merged with xi only when its rank = i-1
  3. So we can say the below statement:
  4. rank(xi)=rank(yi)>=i-1
  5. Now as yi became child of xi, we can remove one more child of yi at max
  6. Then rank(yi)>=i-1-1 >= i-2
  7. Or in other words: rank(xi)=rank(yi)>=i-2

When we see below diagram:

Fibonacci_rank_explained


If you see that in the above diagram for i>=2 for every node the property is satisfying, that if you take any child of Fi it has rank >=i-2, 
As an instance lets take third child of F3, its(third child) rank is 1. (Recall rank is #children)

And quickly just check for every child of Fi whether the property holds true or not.

Note: For i<2 the rank is 0. So only check for i>=2

If you look closely then you will find that last child of Fi  is copy of (Fi-2th in the series).
And the if we ignore the last child of Fi then we could see that Fi-1th tree(in the series).

So this leads us to the below formula:

Minimum number of nodes in F(k) = Minimum number of nodes in F(k-1) + Minimum number of nodes in F(k-2)

Or Simply:
                   F(k) = F(k-1) + F(k-2)

Which is a Fibonacci Sequence formula hence its name Fibonacci Heap.

You also have seen that number of nodes are in Fibonacci sequence in above image.

Now let's proceed further to prove how rank is bounded by lgn:

Let's say we have a Fibonacci Heap H, rank(H) is r, total number of nodes are = n,

By Definition:
F(r) is minimum number of nodes which should be there in Fibonacci Heap whose rank is r.

So,                             n> = F(r)
And we know that, F(r)  = F(r-1) + F(r-2)
                         So,    n >= F(r-1) + F(r-2)
                                  n >= 2*F(r-2)                                                      1.1
Now lets solve 2*F(r-2), and F(0) is 1.

Solve this using back substitution:
=2*F(r-2)
=2^2*F(r - 2*2)
=2^3*F(r - 3*2)
=2^4*F(r - 4*2)
.....
=2^k*F(r - k*2)                                                                                    1.2

So put, 
=> r - k*2 = 0       , as F(0) = 1
=> k = r/2
Now our expression 1.2 will become

=> 2^(r/2)*1 = 2^(r/2)

Put this in expression 1.1
=> n >= 2^(r/2)   or  
=> 2^(r/2) <= n                                                                                   1.3

Take lg to both sides in expression 1.3, we will get below expression:

=> r = 2*lgn

So rank r is O(lgn)


Thanks for Reading
Have a good one!

Comments

Popular posts from this blog

Goodness of Fit Test for normal and poisson distribution

Meaning of Goodness of fit test: We find out which distribution fits the sample data the most. And this is achieved using chi-square distribution (Snedecor and Cochran, 1989). How to apply: There are 4 steps to follow: State the hypothesis:  Data follows a distribution or not Criteria to reject null hypothesis: if Χ 2  > Χ 2 (k,1-α) then reject null hypothesis. Analyze sample data: Compute the chi-square value using below formula: ∑(Oi- Ei) 2 /Ei        : Oi is observed frequency and Ei is expected frequency Interpret the results: Declare the results after comparing the values of Χ 2 and Χ 2 (k,1-α), where k is degree of freedom and  α is significance level. Degree of Freedom: It is  =  n - 1 - m m: number of parameter in the distribution. So in case of normal distribution m is 2 ( μ ,α) and in case of poisson dist. m is = 1 ( λ). Example 1: Goodness of fit test for Normal Distribution Year wise d...

classification of database indexing

Dense Index: For every records we are having one entry in the index file. Sparse Index: Only one record for each block we will have it in the index file. Primary Index ( Primary Key + Ordered Data )  A primary index is an ordered file whose records are fixed length size with 2 fields. First field is same as primary key and the second field is pointer to the data block.  Here index entry is created for first record of each block, called ‘block anchor’. Number of index entries thus are equal to number of blocks Average number of block accesses are = logB (worst case) + 1 (best case),  So on average it will be O(logB) The type of index is called sparse index because index is not created for all the records, only the first records of every block the entry is made into the index file. Example on Primary Index Number of Records = 30000, Block Size = 1024 Bytes, Strategy = Unspanned, Record Size = 100 Bytes, Key Size = 6 Bytes, Pointer Size = 9 Byt...

Reliable User Datagram Protocol

RUDP provides  a solution where UDP  is too primitive because guaranteed-order  p acket  delivery is desirable, but  T CP  adds too much overhead.  In order for RUDP to gain higher Quality of Service , RUDP implements features that are similar to TCP with less overhead. Implementations: In order to ensure quality, it extends UDP by means of adding the following features: Acknowledgment of received packets Flow control Re-transmission of lost packets Over buffering (Faster than real-time streaming) RUDP is not currently a formal standard, however it was described in an n 1999. It has not been proposed for standardization. Working Example: One way to think about how RUDP types of transport work is to use a basic model where all the data is sent in UDP format, and each missing packet is indexed.  Once the main body of the transfer is done, the recipient sends the sender the index list and the sender re-transmits ...