Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Latest commit

 

History

History
22 lines (17 loc) · 637 Bytes

pop_heap.md

File metadata and controls

22 lines (17 loc) · 637 Bytes

pop_heap

Description : This function is used to delete the maximum element of the heap.

Example :

    //sample vector
    std::vector<int> v1 = {2,5,8,7,4,5};
    
    //converting vector into heap
    make_heap(v1.begin(),v1.end());
    //printing first element
    std::cout << "first element of the heap: " << v1.front() << std::endl;
    //outputs 8
    
    pop_heap(v1.begin(),v1.end());
    //pops the maximum element in the heap
    //printing frist element
    std::cout << "first element of the heap after using pop_heap: " << v1.front() << std::endl;

Run Code