JavaScript Algorithms and Data Structures: Priority Queue

Priority queue is a data structure that orders elements by their priority. Learn how to implement it in JavaScript and use it in algorithms like Dijkstra's Shortest Path and Job Scheduling.

In computer science, a priority queue is an abstract data type which is like a regular queue or stack data structure, but where additionally each element has a "priority" associated with it. In a priority queue, an element with high priority is served before an element with low priority. If two elements have the same priority, they are served according to their order in the queue.

While priority queues are often implemented with heaps, they are conceptually distinct from heaps. A priority queue is an abstract concept like "a list" or "a map"; just as a list can be implemented with a linked list or an array, a priority queue can be implemented with a heap or a variety of other methods such as an unordered array.

References

Read this in other languages: 简体中文, Русский, 日本語, Français, Português

The Original Article can be found on https://github.com 

#javascript #algorithms #datastructures

 

JavaScript Algorithms and Data Structures: Priority Queue
5.05 GEEK