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 data is given about number of car accidents, find out w

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 Bytes, Then find avera

Red Black Tree Insertion in Java

Red Black Tree is a binary search tree. With extra property with each node having color either RED or BLACK. It has following properties: Every node is either RED or BLACK Root element will have BLACK color. Every RED node has BLACK children. Every path from root to leaf will have same number of BLACK nodes. We have few theorems over RB tree: Note: Height of RB tree is θ(logn). Insertion: Insertion in RB tree is little tricky as compared to BST, we have following cases to insert a node in RB tree: When tree is null just insert the node and it will be root, color will be BLACK. To insert an element first find its position: if key <= node.key then move to left else move to right Once we find the correct place to insert, we insert the node with color RED. But if the parent of the node just inserted has color RED then it will violate 3 property. So we have to fix this issue. We call it double RED problem, we resolve it using following few cases. DOUBLE R