Fibonacci bunch problem

I have been working on a Fibonacci Heap implementation in Java for about a week now. This implementation is based on the CLRS book.

I wanted to see if I would improve the performance gain by using it in a side project I am working on versus the default Java PriorityQueue. [The default implementation in Java is array-based, so much more local. It can still outperform the F-heap despite higher difficulty scores.

My problem seems to stem from the consolidated part of the heap after deleting the min element. I keep getting arrayindexoutofboundsexceptions thrown. Particularly in a while loop when it concatenates all nodes with the same degree. It exceeds the bounds set by D ().

So either my D () function is wrong, which I don't think it is, or something else is going on. Most likely a side effect.

The code is here . I've been trying to debug this for a week now, good luck. Am I missing something?

+2


source to share


1 answer


You will need to check the parsing as I'm not sure if the upper bound of the degree of a node shouldn't be floor. In your D function, your cast to int truncates the decimal part. Changing this rounding seems to fix the out of bounds index error.



However, there seems to be an additional problem. I haven't tracked down what the conditions are, but lists of children can end up with no setting. This results in an infinite loop in removeMin as it traverses the child list as they are circular.

+1


source







All Articles