1

I want to show that a Fibonacci heap with n nodes could have height n.

I tried this with examples but I don't know how to show this in general.

templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
Rat565
  • 91
  • 2
  • 4

1 Answers1

28

(I assume you mean height n - 1: height n is impossible since with n nodes the maximum height is a linked list of height n - 1)

Getting to height one is easy: add in three nodes, then do a dequeue-min. This removes one node and combines the other two nodes, which have height 0, into this structure of height 1:

A
|
B

If you repeat this process again and ensure one of the new nodes has the lowest priority, you get two of these trees, which are then merged together like this:

A
|\
B C
  |
  D

Now, do a delete operation on B. This leaves A with order 1 and a mark:

A*
|
C
|
D

Repeat this process again (insert three nodes, all of which have infinite negative priority, and call dequeue-min) to get this:

E
|\
F A*
  |
  C
  |
  D

Delete F to get

E*
|
A*
|
C
|
D

If you repeatedly execute this process of adding three nodes, deleting one, then deleting the singleton child of the single remaining tree, you can make the Fibonacci heap a single tree of height n - 1 for any n you'd like.

Hope this helps!

templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
  • But its not for n-1 but for "n". It must be able to reach the heigth "n" of with "n" nodes. – Rat565 Jan 13 '13 at 10:10
  • Do you got no idea for n hight? – Rat565 Jan 13 '13 at 15:20
  • 7
    @Rat565- As I mentioned in my answer, it's not possible to get height n. The height of a tree with one node in it is zero, so the height is always at most one less than the number of nodes. If you define the height of a single node to be one, though, then this works. Also, please don't be so ungrateful. Looking over your question, I get the sense that I'm doing your homework for you. You could at least be appreciative that I've put an effort in to help out. – templatetypedef Jan 13 '13 at 19:11
  • I m really gratefull. But i neeted help for normal n. ;) – Rat565 Jan 13 '13 at 20:47
  • 5
    @Rat565- Again, are you absolutely positive it's exactly n? It's mathematically impossible for that to work. A common question is whether it's possible to get a chain of n nodes, which is what I've shown above, but that's not the same as just having height n. – templatetypedef Jan 13 '13 at 20:51
  • @templatetypedef will it be possible to show the steps you skipped, I would have done that but I don't think I completely understand them. Also 'dequeue-min' and 'delete operation on B' these steps are not valid for trivial Fibonacci heaps, so it would be great if you can just restrict to INSERT,EXTRACT-MIN, DECREASE-KEY in your explanation. – sapy Mar 06 '19 at 01:09
  • Also "ensure one of the new nodes has the lowest priority" step , if C or D has lowest priority (I assume they are new min) then resulting tree will have C or D as root , how come A is the root after that operation ? – sapy Mar 06 '19 at 01:11
  • It is not possible for a standard Fibonacci heap! – NiRvanA Mar 14 '22 at 22:18