How to show Fibonacci heap with n nodes can have height n? [closed]

戏子无情 提交于 2019-12-08 09:07:28

问题


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.


回答1:


(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!



来源:https://stackoverflow.com/questions/14300256/how-to-show-fibonacci-heap-with-n-nodes-can-have-height-n

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!