0

For integer value priority queue can maintain the order but what if we want to use it to store nodes?

  • You need to define an ordering for nodes, either globally or by passing a parameter to the priority_queue. A bit more context will help you get a more useful answer. What is the definiton of node, and how do you want them to be ordered in the priority_queue? – john Jul 17 '20 at 08:23
  • you need to define how the nodes are ordered, this can be done using compare class and overriding operator function. – Ram Prabodh Induri Jul 17 '20 at 08:28
  • 1
    Does this answer your question? [declaring a priority\_queue in c++ with a custom comparator](https://stackoverflow.com/questions/16111337/declaring-a-priority-queue-in-c-with-a-custom-comparator) – Ram Prabodh Induri Jul 17 '20 at 08:32

0 Answers0