You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Indigo2233
changed the title
BinaryHeap constructor performs different from heapify
BinaryHeap constructor performs differently from heapify
Jun 29, 2020
I recommend asking on julialang slack or Discourse.
The code change should be fairly straight forward if you are familar with the constructor in question and the heapify function
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
andy
have the same order: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.
The text was updated successfully, but these errors were encountered: