JuliaCollections / JuliaCollections/DataStructures.jl
BinaryHeap constructor performs differently from heapify
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 745
- Forks
- 261
- PR merge metrics
- No merged PRs in 30d
Description
I noticed that BinaryHeap like BinaryMinHeap constructs a heap that just insert every element from an array to a empty heap. And the following x and y have the same order:
julia> nums = rand(1:20000, 2000);
julia> x = MutableBinaryMinHeap(nums);
julia> y = BinaryMinHeap(Int.([]));
julia> for i in nums
push!(y, i)
end
However, there is an O(N) heap-building algorithm instead of O(NlogN), and function heapify is an implement. So why not use heapify instead of insert successively?
Sincerely.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect the BinaryHeap and BinaryMinHeap constructors and the existing heapify function mentioned in the issue. Compare the constructor with the provided successive-push examples. Done means construction uses the linear-time heap-building approach while preserving the observed heap behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100