/* THIS CODE HAS BEEN TESTED AND IS FULLY OPERATIONAL. Problem Statement: Consider a scenario for Hospital to cater services to different kinds of patients as Serious (top priority), b) non-serious (medium priority), c) General Checkup (Least priority). Implement the priority queue to cater services to the patients. Code from DataStructuresAndAlgorithms (SPPU - Second Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-se-comp-content/DataStructuresAndAlgorithms/ */ // BEGINNING OF CODE #include #include #include using namespace std; // creating LinkList class Node { public : Node *next; int priority; string data; Node(string d,int prior){ priority = prior; data = d; next = NULL; } }; class PriorityQueue{ public: Node *front=NULL; //d is patient name , prior is priority void insert(string d,int prior){ Node *temp,*rear; temp = new Node(d,prior); if(front == NULL){ front = temp; } else { //compare until position is found rear = front; while( rear->next!=NULL && rear->next->priority >= prior ){ rear=rear->next; } temp->next = rear->next; rear->next = temp; } } //to get name of first patient void peek(){ cout<<"First patient is:\t"<data; } void pop(){ //to remove first patient if(front==NULL) return; front=front->next; } //display all the queue void dis() { string currPrior=""; if(front== NULL){ cout<priority!=0){ if(curr->priority==3) currPrior="Serious patient"; else if(curr->priority==2) currPrior="Not serious patient"; else currPrior="General checkup"; } cout<data<<" with priority:\t"<next; } } }; int main(){ string name; int priority,ch; cout< Add patient"; cout< Remove patient"; cout< Get all patients"; cout< Exit"; cout<>ch; switch (ch) { case 1: { cout<<"Patient name is:\t"; cin.ignore(); getline(cin,name,'\n'); cout<>priority; q.insert(name,priority); break; } case 2: { q.pop(); break; } case 3:{ q.dis(); break; } case 0: cout<