Question: Build a print scheduler using a priority queue represented with a maximum binary heap as the data structure. Each print request has the following associated

Build a print scheduler using a priority queue represented with a maximum binary heap as the data structure. Each print request has the following associated fields: ID, users login name, request time, priority, file size in bytes, and file handle.

Write a program that supports the following operations:

int add(string login, string time, int priority, int size, int handle): add a new request to a queue; return a sequential ID# if successful, or FULL if the total file size of all pending requests exceeds the maximum spool size of 50MB. The input argument handle is not used in this exercise, so set it to NULL. The ID cycles in the range of 1 - 1024.

int print_next(): return EMPTY if the queue is empty, or return the ID of the pending highest-priority request and delete it from the queue.

int find_next(): return EMPTY if the queue is empty, or return the ID of the pending highest-priority request.

int cancel(string login): delete all the requests made by the login user; return the number of deleted requests if successful, or return NONE if not found.

int cancel(int ID): delete the request with the ID; return 0 if successful, or return NONE if not found.

String status(): return a string containing information about all pending requests' ID, login, creation time, priority, file size, and file handle; return EMPTY if there's no pending request. The order of the print requests returned does not matter.

Error codes: -1 for FULL, -2 for EMPTY, -3 for NONE. (If you add more error codes, clearly state them in your program code.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!