PRIORITY QUEUES

In this blog post will study why to use priority queues, applications, operations and C++ code file for implementation of ordinary queue.

Why to use them?

In special cases for example; job applications, the list of applications will be set in queue but in some cases there will be some priority given to cenrtain applicants whose application will be processed earliar irrespective of the waiting queue.

So to implement this, we can either enqueue the data as they come and dequeue the data with highest/minimum priority or enqueue in order and dequeue as usually from front.

In this post, we shall see the first method. We shall input the item as they come and delete the minimum value from the queue.

Applications

  • Data compression: Huffman Coding algorithm
  • Shortest path algorithms: Dijkstra’s algorithm
  • Selection problem: Finding kth- smallest element
  • Event-driven simulation: customers in a line
  • Minimum spanning tree algorithms: Prim’s algorithm

Standard Operations

  1. Enqueue: Insert a new item at the rear end of the queue. If there is no place then queue is in overflow state.
  2. Dequeue: Remove an item from the front end of the queue. Find out the minimum value in the queue and remove it. If there are no elements then the queue is in underflow state.
  3. isEmpty: To check whether queue is empty or not.
  4. isFull: To check if queue is full or not.
  5. Display Display the items in the queue.

Code file

Please open this in your pc or with a compatible app in your mobile.

C++ Implementation for PRIORITY QUEUES

That's it from this blog post. If you liked it then do share this blog with your friends or people who wanna get into programming world. Thank You!

Copyright © NStF Blogs 2021