Priority queues

A priority queue makes it possible to extend the concept of a queue by setting priority for each element in the queue. It is worth mentioning that the priority can be specified simply as an integer value. However, it depends on the implementation whether smaller or greater values indicate higher priority. Within this chapter, it is assumed that the highest priority is equal to 0, while lower priority is specified by 1, 2, 3, and so on. Thus, the dequeue operation will return the element with the highest priority, which has been added first to the queue, as shown in the following diagram:

Let's analyze the diagram. First, the ...

Get C# Data Structures and Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.