• Home
  • Blog
  • In this assignment, we will be building a simulation of a job scheduling and processing system. The purpose of the simulation is to be able to run simulations in order to compare their performance, when they use different queuing disciplines in order to .

In this assignment, we will be building a simulation of a job scheduling and processing system. The purpose of the simulation is to be able to run simulations in order to compare their performance, when they use different queuing disciplines in order to .

0 comments

Create a PriorityQueue class and implement a new enqueue() method to implement a priority queuing

discipline. For efficiency, priority queues are often implemented using a heap, so that both insertion and removal

of items can be done in O(log n) time. However, we are going to use a simple naive method and simply insert

new items into a link list that we keep sorted by priority. Doing this means that the insertion (enqueue())

operation becomes O(n), but since for a priority queue we always want the next item with the highest priority

for a dequeue(), dequeue() is still O(1) constant time, since we will keep items ordered by priority and the

highest priority item in the queue should always be at the front of the list.

This may sound like a lot, but there is really not too much to do to get a basic priority queue working. You

need to perform the following steps

1. Create a new class called PriorityQueue that inherits (using public inheritance) and derives from the

LQueue class. This class still needs to be a template class, as it needs to be able to handle queues of

different types of objects. I have set the member variables of the LQueue class to be protected, which

means that your PriorityQueue class methods will be able to access and refer to the queueFront and

queueBack member variables. You should insert your class definition for your PriorityQueue at the end

of the “Queue.hpp” file.

The only method you need to implement/override is the enqueue() method. All other methods should work

correctly using the LQueue() implementations you will inherit. But since you are overriding enqueue()

you do need to put a new declaration for this function in your PriorityQueue class declaration, but this

will be the only function or variable (re)defined in the PriorityQueue.

2. Once you have the declaration working, you will need to create your implementation of the enqueue()

method for the PriorityQueue. As we already mentioned, instead of always just inserting the new

item/node at the back of the queue, you instead need to do some some extra work and insert the new node

into the linked list at the proper position so that the linked list is ordered by priority. You can assume that

the objects inserted into a PriorityQueue are overloaded so that boolean comparisons (like operator<,

operator<=, operator>, etc.) are defined to order object by their priority. The Job class that you will be

managing with your PriorityQueue has had these operators defined to order jobs by their priority level.

The pseudo-code for the algorithm your enqueue() function needs to perform

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}