How to remove item from heap efficiently?

srinivas devaki mr.eightnoteight at gmail.com
Wed Jan 13 10:34:26 EST 2016


On Wed, Jan 13, 2016 at 4:50 PM, Cem Karan <cfkaran2 at gmail.com> wrote:
>
> Is that so?  I'll be honest, I never tested its asymptotic performance, I just assumed that he had a dict coupled with a heap somehow, but I never looked into the code.
>

I have just tested the code, the aymptotic performance is O(log(n))
for all operations. Infact the code is very simple to understand,
technically the heapdict class is composed of a dict and heap, each element of
heap is a mutable list and dict stores references to that mutable list,
so that a specific element can be deleted in O(log(n))



More information about the Python-list mailing list