is_heap(): This function is available in the file stl_heap.h. This function checks the range of elements is in the heap or not. If the range is in the heap it will return true. Otherwise, it will return false.
Parameters: Two parameters are required for this function.
__first – Start of range.
__last – End of range.
Syntax:
is_heap(__first, __last)
For Example:
arr = {7,5,6,2,3,1,2}
is_heap(ar.begin(),arr.end()) = > It will return true (1)
Approach
C++
#include <bits/stdc++.h>using namespace std;int main(){vector<int> arr = {7, 5, 6, 3, 4, 1, 2};cout << is_heap(arr.begin(), arr.end()) << "\n";return 0;}
No comments:
Post a Comment