Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In the outpatient department of an hospital, where there is a single doctor for

ID: 3558071 • Letter: I

Question

In the outpatient department of an hospital, where there is a single doctor for consultation, patients are issued tokens in increasing order of their arrival. The token also carries a number indicating the severity of the case of a patient. For example, if a patient with a cold and cough comes at 9.55AM, he gets a token number 10 and priority number 3 whereas when a patient with a heart attack comes at 10 AM, he gets a token number 11 and priority number 1. The hospital staff routes the patient with highest priority number to the doctor

Explanation / Answer

#include <iostream>
using namespace std;

struct Node{
int info;
Node *next;
};

class QueueADT{
private:
Node *qFront;
Node *qRear;

public:
QueueADT(){ //constructor
qFront = 0;
qRear = 0;
}
bool isEmpty(){
if (qFront==NULL) return(true);
else return(false);
}
int dequeue(){
int data;
data = qFront->info;
qFront = qFront->next;
if (qFront==0) qRear = 0;
return data;
}
void enqueue(int data){
Node *temp = new Node();
temp->info = data;
temp->next = NULL;

if (qFront == 0) {
qFront = qRear = temp;
}
else{
qRear->next = temp;
qRear = temp;
}
}

};

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote