not able to undestand the line no 40 of the code given in video.
Doubt in heap lecture
can you tell the time stamp
and also type the line which you didn’t understand
because at line no 40 nothing is written
time - 4:00 ,priority_queue<person,vector,personcompare>pq;
okay
this is a way to create min priority_queue(min heap, min element at top)
because by default priority_queue is max heap (max element at top)
we have to pass 3 things here
- data type
- a container of that type
- comparator
why are we passing vector in priority queue and why arent we passing anything in person compare?
this is a syntax to create min priority queue
you have to pass an container like vector and also a compator
else you can also use your own min heap (implement it from scratch)
thats means just like we pass arguments in functions thats how we use the syntax in function, and same is here? for priority queue?
how are we passing person1 and person 2 in person compare? written in priority queue line? here we have just written Person compare, what is the logic?
in the sorting to sort the elements we have to compare 2 values
similarly in heap implementation we have to swap according to type of heap
so this swapping happens based on compare functions