I was trying to learn about fibonacci heaps, the pseudocode for inserting an element in the heap was:
Fibonacci-Heap-Insert(H,x)
degree[x] := 0
p[x] := NIL
child[x] := NIL
left[x] := x
right[x] := x
mark[x] := FALSE
concatenate the root list containing x with root list H
if min[H] = NIL or key[x]<key[min[H]]
then min[H] := x
n[H]:= n[H]+1
Here are some things i did not understand,
- What is
root list containing x
and how to concatenate it with root list containing H?
While extracting min we do something like this:
Fibonacci-Heap-Extract-Min(H)
z:= min[H]
if x <> NIL
then for each child x of z
do add x to the root list of H
p[x]:= NIL
remove z from the root list of H
if z = right[z]
then min[H]:=NIL
else
min[H]:=right[z]
CONSOLIDATE(H)
n[H] := n[H]-1
return z
(Here are the other functions, consolidate and link, http://www.cse.yorku.ca/~aaw/Jason/FibonacciHeapAlgorithm.html)
In the previous insert function, we set child, and p of x as nil, the while extracting min,
if <> nil
will always be false and so it will never give and accurate min if we call the function several times.If this structure is called a Fibonacci 'heap', where does it maintain the heap property?
If we use a binary heap in Dijkstra's Algorithm instead of a fibonacci heap will the time taken be almost as slow as it will be if we use an array or a linked list?
Can anyone explain the difficulties I have? Thank you.