Back to course home
0% completed
Vote For New Content
# move the element to the end and delete it heap[ind] = heap[-1] del heap[...
Dylan Asoh
Aug 30, 2022
move the element to the end and delete it
heap[ind] = heap[-1] del heap[-1] i don't understand the comment. aren't you moving the element at end to ind, not ind to end?
1
0
Comments
Comments
A
anadi.jaggia 3 years ago
I have the same question :( Hopefully someone can help
Design Gurus3 years ago
The comment is misleading. We have fixed it.
We copy the last element on this index, decrease the size of the heap (that is, delete the last element), and shift the element up/down to keep the heap property.
On this page