Help with the following C ++ tasks:

  1. Apply built-in language tools to rebuild an array into a binary heap, add an arbitrary element, and extract the maximum element from the binary heap.
  2. Apply built-in language tools to sort the pyramid.

I already have these algorithms implemented on bare C ++, but I don’t know what standard means the language has for these tasks, and Google doesn’t find anything.

1 answer 1

These are the following algorithms for working with the heap, declared in the header of <algorithm> :

  1. make_heap() converts a range of elements into a heap.
  2. push_heap() adds one item to the heap.
  3. pop_heap() removes the next item from the heap.
  4. sort_heap() converts the heap into a sorted collection, after which the heap is no longer a heap.
  5. is_heap() checks if a range of elements is a heap.