std::priority_queue In C++



In this video we will learn about std::priority_queue in C++ STL. NOTES: 0. std::priority_queue is a container adaptor that provides constant time lookup of the …

Tag: priority queue c++, [vid_tags]
Xem thêm: https://meohay360.com/category/internet

Nguồn: https://meohay360.com

19 thoughts on “std::priority_queue In C++

  1. Milan Shah says:

    Thanks a lot for the video but I have a few questions:

    1. First of all, if we want to order something in ascending order then it is the by default thing or we can pass `std::less` operator. But, here to sort everything, we are passing `std::greater` operator! Doesn't it seem strange?

    2. As you mentioned, to sort in ascending order we have to write like: `std::priority_queue<int, std::vector<int>, std::greater<int> >` But, why are we passing `std::vector<int>` and not just `std::greater<int>`? In the case of vector, we just pass `std::greater`, right?

    And if we have to pass `std::vector<int>` then why that's not the case with descending order? I mean by default it will assume `std::less<int>` operator but what about `std::vector<int>`? It will assume that one too?

    Thanks in advance!

  2. Harsh _ says:

    I love your videos.and i started programming last year..Can u make a video on how to use cpp for competitive programming.that will be very helpful..or recommend questions on stl topics and data structures.for practice.🙏🙏

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *