Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <algorithm>
    #include <vector>
    using namespace std;
    int main ()
    {
    int Numbers[] = {100, 200, 300, 50, 150};
    vector<int> Data(Numbers, Numbers + 5);
    make_heap (Data.begin(), Data.end());
    pop_heap (Data.begin(), Data.end());
    Data.pop_back();
    cout << Data.front();
    return 0;
    }
    1. 100
    2. 200
    3. 300
    4. 50
    5. 150
Correct Option: B

In this program, We are forming a heap with the vector and then we are popping one element and finding the maximum element in the heap.



Your comments will be displayed only after manual approval.