Complete the code to declare a max heap using C++ STL priority_queue.
std::priority_queue<int> [1];The variable name can be anything, but 'pq' is commonly used for priority_queue.
Complete the code to get the index of the left child of a node at index i in a heap array.
int leftChild = 2 * [1] + 1;
In a heap stored as an array, the left child index is calculated as 2*i + 1.
Fix the error in the code to check if a node at index i has a right child in a heap of size n.
bool hasRightChild = (2 * i + [1]) < n;
The right child index is 2*i + 2, so to check existence, compare 2*i + 2 < n.
Fill both blanks to calculate the parent index of a node at index i in a heap array.
int parent = ([1] - [2]) / 2;
The parent index is calculated as (i - 1) / 2 in a heap array.
Fill all three blanks to create a min heap using C++ STL priority_queue with a custom comparator.
std::priority_queue<int, std::vector<int>, [1]<int>> [2]; // Min heap // Insert element [3].push(10);
To create a min heap, use std::greater<int> as comparator and name the variable 'pq'.