Question: For this assignment, implement a C + + program to track patients entering and leaving a hospital emergency room. Patients coming into the emergency room
For this assignment, implement a C program to track patients entering and leaving a hospital emergency room.
Patients coming into the emergency room are assigned a priority by the triage team and then wait in the waiting
room for a healthcare provider. When a healthcare provider becomes available, the patient with the highest
priority is called and removed from the waiting room.
A heap is a good choice to implement a priority queue, which is what we need for this problem. Implement a
class for an arraybased heap using the algorithms discussed in the videospdfs and in your textbook. It should
support the following operations at minimum:
ads
adds a new patient to the waiting room heap. returns true if successful, false if not.
F
retums the next patient to be served, ie the patient with highest priority in the heap does not remove the
patient from the waiting room heap
re
serves the next patient, ie removes the patient with the highest priority from the waiting room heap. returns
true if successful, false if not.
Each Patient needs to have both a priority and data. For this assignment, to keep things tractable, you can use a
hack. Each Patient in the heap will be a string. The first character of the string is a single digit integer indicating
the priority, followed by a space, followed by the first name of the patient. The priority can be any integer
between and with being the highest priority and being the lowest. For example, we could have three
patients in the waiting room:
Mary" patient Mary with priority
patient Bob with priority
Max" patient Max with priority
The string class can compare strings using the and operators, and the above strings are in fact sorted
from highest to lowest due to the leading integers. Your heap array can thus be an array of string objects.
Submission
Submit your code base, and sample output showing a sequence of patients of various priorities entering and
leaving the waiting room via Canvas. You do not need to demonstrate error conditions ie inserting too many
patients to the heap or trying to remove patients from an empty heap When you output a patient, it's ok to
output the patient's priority as well, eg Bob will now see the doctor." At a minimum, show output for the
following sequence of events:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
