Operations

Report Min - O(1) Worst Case

Trivially, min is always at the Root

Decrease Key - O(1) Worst Case

To decrease the key of node x to v

  1. If x is the root - DONE
  2. If v is smaller than the root value, swap the two values
  3. Cut the subtree rooted at x and link it to the root
  4. Perform ≤ 1 Loss Reduction
  5. Perform ≤ 6 Active Root Reduction and ≤ 4 Root Degree Reduction

Effects on Invariants

Merge - O(1) Worst Case

To merge H1 and H2, and w.l.o.g assume size(H1) ≤ Size(H2)

  1. Make all nodes in H1 passive - This can be done in O(1) and will be shown in the next section
  2. Link H1 and H2 such that the root with a smaller key becomes the new root
  3. Set the new Q to be Q1 + larger Root of H1 and H2 + Q2 (note Qi is the Q for Hi)
  4. Perform 0 or 1 Active Root Reduction and 0 or 1 Root Degree Reduction

Effects on Invariants

Insert - O(1) Worst Case

Assume we want to insert node x

  1. Create one heap with a passive node x
  2. Merge it with the main heap

DeleteMin - O(LogN) Worst Case

  1. Scan through the children of the root and find node x with the minimum value
  2. Make x passive
  3. Link all the other children of the root to x.
  4. Remove x from Q, delete the original root and make x the new root.
  5. Do this twice: move the first node, y, in Q to the back. If y has two passive children, link both to the root.
  6. Perform 0 or 1 Loss Reduction.
  7. Perform O(LogN) numbers of Active root reduction and Root Degree Reduction until none is possible. (Note we need O(LogN) times because every 2 Active root reduction + 3 Root Degree Reduction reduces root degree by 1, and the new root degree increases by at most 2logN + 12 + 4(By I5 and there are ≤ 4 new nodes from step 5), and Active Roots increase by at most R(by Lemma 2, x had at most R active children)

Effects on Invariants

  • I1: Trivially, no effects as no new active nodes are formed.
  • I2: This could be violated by at most 1 because R and N are decreased while the total loss remains the same. However, by Lemma 3, we can perform one loss reduction in step 6 to bring it back within the range.
  • I3: As mentioned above, Active Roots are increased by at most R, so we will perform step 7 O(logN) times to bring it down.
  • I4: As mentioned above, root degree is increased by at most 2logN + 12 + 4, so we will perform step 7 O(logN) times to bring it down.
  • I5: Since N is decreased by 1, the constraints are strengthened. And this is why we perform step 5. By removing two nodes to the back, all the other nodes have p decreased by 2 or 3 (depends on if the node was before or after the new min node). Thus, 2n - p does not increase and the constraints remain valid for these nodes.

    For the two nodes that are moved back to the Q, their constraints reduced from, e.g. for Node 1, 2log(2oldN - 1) + 9 to 2log(2oldN - 2 - (oldN - 2)) + 9, or decreased by 2. But if this violates the rule, given it has ≤ R active nodes, it must have two passive nodes for us to link to the root. Otherwise, no violation.

  • So, all 5 invariants are kept after Merge

  • The analysis on this site is based on Strict Fibonacci Heaps