why we use vector as parameter while creating min heap
Min heap STL related doubt
Basically, heap is a data structure in which we have 2i as left child and 2i+1 as right child respectively, these values can be stored easily inside an array. since it is much easier to insert the elements into vector as compared to arrays and hence we use vector.
ma’am this is not my doubt
i am asking about heap STL why we use vector when we create min heap .
e.g->
priority_queue<int ,vector , grater> heap;
in case of max heap we do not pass vector as argument.
in min heap why we pass vector and why we do not pass vector while creating max heap.
This is because by default, if we use priority queue , max heap is created, whereas if we wish to create min heap , then you need to use this kind of syntax only, where you need to pass vector as argument and also need to use a comparator function for the same.