java - How to get the minimum element from a priority queue after modifying the contents of queue -
this question has answer here:
i trying implement dijkstra's algorithm using priority queue
in java.. unfortunately returning wrong results...i have tracked down problem. here's problem..after inserting node weights queue,i modifying node weight,but when try remove element priority queue ,its returning historical minimum (minimum @ time of insertion).remove()
doesn't know priority queue has been modified..any appreciated ...thanks!
note:i can add source code if required
this question should you. drawback priorityqueue in java if inserted element value changes, priority queue not re-constructed reflect new order. have remove , re-insert changing elements satisfy use case.
Comments
Post a Comment