Science, asked by sonalibetageri621, 1 year ago

Why one should use Heap where we have STL (set)?

Answers

Answered by snake95939528
0

Internally, a heap is a tree where each node links to values not greater than its own value. In heaps generated by make_heap, the specific position of an element in the tree rather than being determined by memory-consuming links is determined by its absolute position in the sequence, with *first being always the highest value in the heap.

Heaps allow to add or remove elements from it in logarithmic time by using functions push_heap and pop_heap, which preserve its heap properties

Similar questions