Possible Duplicate:
How can I implement decrease-key functionality in Python's heapq?
Hi,
I'm using heapq in Python to implement a priority queue. The items inside the queue get their priorities changed a lot, and when that happens I need to heapify the heapq.
The problem is that heapq only has a heapify function that heapifies the entire heap, rather then heapify that starts off from a certain item inside the heap knowing that the rest is already a well ordered heap (like the classic CS text book heapify).
The difference is significant since each heapify call is O(n) instead of O(lgn).
Can it be done without implementing a heap using a standard list?
Thanks!
It seems that my question is a duplicate of How can I implement decrease-key functionality in Python's heapq?
The answer there indicates that there's no way around reimplementing a heap based queue with proper O(lgn) heapify of a specific item.