Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Binary heap implementation proposal #11
In this pull request, I propose a binary heap implementation as alternative to fibonacci heap. Altough its amortized complexities are greater than Fibonacci's, this array-backed implementation is simpler, more memory-efficient, has better spatial locality (i.e. less indirections) and may be faster for reasonable heap sizes.
In this pull request you'll find a benchmark that shows this point.
Please note that I didn't implement the methods change_key and delete, since it doesn't make too much sense in a binary heap. It would require an additional hashmap to keep track of stored keys, and much of the memory efficiency would be lost.
It's just an implementation proposal. It may not comply with the library coding style. You may eventually realize that neither Ruby nor English are my main languages :)