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 Array[] = {12, 1, 13, 51, 25};
    vector<int> VectorData(Array, Array + 5);
    make_heap (VectorData.begin(), VectorData.end());
    pop_heap (VectorData.begin(), VectorData.end()); VectorData.pop_back();
    VectorData.push_back(50); push_heap (VectorData.begin(), VectorData.end());
    sort_heap (VectorData.begin(), VectorData.end());
    for (unsigned k = 0; k < VectorData.size(); k++)
    {
    cout << ' ' << VectorData[k];
    }
    return 0;
    }
    1. 1 12 13 25 50
    2. 1 12 13 25
    3. 1 12 13
    4. 1 12
    5. 1
Correct Option: A

In this program, We popped out 13 and pushed 50 and then we are sorting that value, So it is printing it.



Your comments will be displayed only after manual approval.