Priority queue

  • An ordered queue

  • Priority queues help consumers consume the higher priority messages first followed by the lower priority messages.

  • Is heap data structure

  • search is still O(N). On the other hand, It is best for finding min/max in a set O(1).

  • add and remove is LogN, due to rebalancing

vs TreeSet

  • Tree set is red black tree

  • https://stackoverflow.com/questions/16540082/what-are-the-differences-between-heap-and-red-black-tree

  • https://www.freecodecamp.org/news/priority-queue-implementation-in-java/

  • https://www.educba.com/priority-queue-vs-heap/

  • https://cs.stackexchange.com/questions/105899/why-use-heap-over-red-black-tree

Last updated

Was this helpful?