Java priority queue min heap

broken image

In case of insertion and changing priority, tree needs to be re-balanced again, which is more complex than maintaining min heap property in heap data structure. It consumes extra space for keeping pointers for each node. Insertion is easy, getting minimum is an easy operation.

broken image

Runtime complexity is O(n^2) in putting minimum element at top each time, a new element has come. Why not other data structure (other than Heap)? (Heap data structure) can be used for its implementation. decrement(index, newValue) - Decrement an element from priority queue.insert(element) - Insert an element into Priority queue.extractMin() - Gives the minimum priority element, and delete it.getMin() - Gives the minimum priority element.And, gives priority to element with minimum value. Min Priority Queue is a data structure which manage a list of keys(values).

broken image