Add build to binary heap #32
No reviewers
Labels
No labels
bug
discussion
documentation
duplicate
ignore
new feature
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
golibs/gms-gods!32
Loading…
Reference in a new issue
No description provided.
Delete branch "master"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This changes allow to build heap from slice in O(n) time.
There was a proposition to add slicer interface(example https://play.golang.org/p/lpOt0Lw_pM) so it will be possible to use construction like:
Are you okay with this solution?
Thanks for contributing. I think having the possibility to build from slice is a great feature for the heap.
I have just two questions:
How about making the the Push function variadic rather than implementing a new function?
Why do we need to call bubbleDownIndex, i.e. why not just call heap.Push invididually which already does the bubbling logic?
Great, thank you very much!
Can you please update the code?
It's a great optimization.
Tomorrow ;)
I'll add this quickly and update comments and documentation
Pull request closed