-
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;
}
-
- 100
- 200
- 300
- 50
- 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.