Triage is a process for sorting injured patients into groups based on their need for or likely benefit from immediate medical treatment. At most veterinary clinics, veterinarians will interrupt...


Triage is a process for sorting injured patients into groups based on their need for or likely benefit

from immediate medical treatment. At most veterinary clinics, veterinarians will interrupt treatment of

a patient if another patient with higher medical priority arrives. Only after higher medical priority

patients have been tended to will resources be once again diverted to lower medical priority patients.








Write a program for a veterinary clinic that will give an estimated time for when all patients will have

been successfully treated. Input from a data file is as follows:

• The first line of input will contain a single integer, n, indicating the number of data sets to process.

The remainder of the input consists of those n data sets. Each data set will consist of two parts:

1. A line containing a single integer, m, indicating the number of patients.

2. Each of the next m lines will correspond with a single patient and be in the format "x y z",

where:

• x is the time the patient arrives at the clinic, specified by the number of minutes (0- 480)

that have elapsed since the clinic opened. Patients are listed in order of arrival, so the x

value for each patient is at least as high as for the previous patient.

• y is the medical priority (1- 5) of the patient, with 1 being the highest medical priority.

• z is the number of uninterrupted minutes (1- 480) of treatment necessary to tend to the

patient.

For each data set in the input display the following to the screen:

• A single line in the form "Set n: a minutes", where n is the data set and a is the number of

minutes that have elapsed since the clinic opened when all patients have been successfully

treated.

Only one patient can be treated at a time (it is a small clinic) and treatment for a patient can only begin

after it has arrived at the clinic. Treatments are started as soon as possible. If two or more patients are

at the clinic awaiting treatment, the one with highest medical priority is treated first. If two or more

have the same highest medical priority, then the one (of those with the highest medical priority) with

the shortest treatment time is treated first. The only time treatment may be interrupted is when a

higher medical priority patient arrives. In this case, the treatment for the lower medical priority patient

is stopped and treatment for the highest medical priority patient begins. For a patient to be successfully

treated, its treatment must be uninterrupted and last the number of minutes specified in the input.

Let the user input the file name from the keyboard. Use a Queue/PQ data structure. Refer to the sample

output below.



Sample File

3

3

0 5 20

19 4 30

48 3 60

7

60 1 30

75 1 60

80 2 10

80 3 5

80 2 5

155 1 10

166 2 5

3

0 3 10

1 3 5

2 4 1

Sample Run:

Enter the file name: triage.txt



Set 1: 158 minutes

Set 2: 185 minutes

Set 3: 16 minutes



Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here