How to implement O(logn) decrease-key operation for min-heap based Priority Queue?

前端 未结 4 1588
孤街浪徒
孤街浪徒 2020-12-04 10:59

I am working on an application that demonstrates the Djikstra\'s algorithm, and to use it, I need to restore the heap property when my elements\' value is decreased

4条回答
  •  醉酒成梦
    2020-12-04 11:19

    If you are using c++ stl make_heap()/pop_heap()/push_heap(), there is no way to keep an index from node id to index in the underline heap vector, I think you should implement your own heap functions to achieve O(logn) in Increase-Key/Decrease-key operation.

提交回复
热议问题