Data Structures Lab
Evaluation 6: Structured Enquiry
KLE Technological University
Dr. M.S. Sheshagiri Campus, Belagavi
2025-26
Sl. No. Team Roll No. Name SRN
No.
A-145 Gururaj Godse 02FE25BCS129
A-146 Nithyashree Binnal 02FE25BCS130
12 A12 A-147 Sakshi Sheetal Patil 02FE25BCS131
A-148 Mohammed Yusuf 02FE25BCS132
Shahajan Nadaf
A Div 2 Sem: 25ECSP104 Darta Structures Lab
2025-2026
Faculty: Prof. Supriya. B
Data Structures Lab
Problem Statement:
In a busy metropolitan hospital’s emergency department, where patient inflow is
unpredictable and often overwhelming, an intelligent triage management system is required
to ensure timely and life-saving medical attention. The system must efficiently handle
incoming patients who arrive with varying degrees of medical urgency, each assigned a
severity level after initial assessment by the triage nurse. These severity levels are
categorized as Critical (C), Urgent (U), Normal (N), and Low (L), with Critical cases
requiring immediate intervention. Unlike a simple first-come-first-served system, this
environment demands dynamic prioritization, where patients with more severe conditions
must be treated ahead of others, even if they arrive later. Additionally, the system should
maintain proper ordering within each severity level to ensure fairness among patients of
similar conditions. Hospital administrators also require periodic insights into patient
distribution across severity levels to optimize staffing and resource allocation. Design an
appropriate data structure to model this priority-based patient handling system and
develop a modular C program that supports patient arrival, prioritized treatment
(dequeue), and basic analysis of patient categories currently waiting for
Explanation of Operations
1. Enqueue (Patient Arrival)
• Inserts patients according to severity priority.
• Critical patients are placed before Urgent, Normal, and Low.
• Same severity patients maintain arrival order.
2. Dequeue (Treatment)
• Removes and treats the highest-priority patient from the front.
3. Display
• Shows all waiting patients in treatment order.
4. Analyse
• Counts patients in each severity category for hospital administration.
Data Structures Lab
C Program:
#include <stdio.h>
#include <string.h>
#define MAXSIZE 20
struct patient
{
int id;
char name [30];
int age;
char severity; // C, U, N, L
};
struct patient queue [MAXSIZE];
int front = -1, rear = -1;
int priority(char s)
{
if (s == 'C')
return 1;
else if (s == 'U')
return 2;
else if (s == 'N')
return 3;
else
return 4; // L
}
void enqueue (struct patient p)
{
if (rear == MAXSIZE - 1)
{
printf("Queue Full! \n");
return;
}
if (front == -1)
front = 0;
int i = rear;
while (i >= front &&
priority(queue[i].severity) > priority([Link]))
{
queue[i + 1] = queue[i];
i--;
}
Data Structures Lab
queue[i + 1] = p;
rear++;
printf("Patient Added Successfully!\n");
}
// Function to attend patient
void dequeue()
{
if (front == -1 || front > rear)
{
printf("No patients in queue.\n");
return;
}
printf("\nDoctor Attending Patient:\n");
printf("ID : %d\n", queue[front].id);
printf("Name : %s\n", queue[front].name);
printf("Age : %d\n", queue[front].age);
printf("Severity : %c\n", queue[front].severity);
front++;
if (front > rear)
front = rear = -1;
}
// Function to display queue
void display()
{
if (front == -1)
{
printf("Queue Empty!\n");
return;
}
printf("\n--- Patient Queue ---\n");
printf("ID\tName\t\tAge\tSeverity\n");
for (int i = front; i <= rear; i++)
{
printf("%d\t%s\t\t%d\t%c\n",
queue[i].id,
queue[i].name,
queue[i].age,
Data Structures Lab
queue[i].severity);
}
}
// Function to analyze patient categories
void analyze()
{
int critical = 0;
int urgent = 0;
int normal = 0;
int low = 0;
if (front == -1)
{
printf("Queue Empty!\n");
return;
}
for (int i = front; i <= rear; i++)
{
switch (queue[i].severity)
{
case 'C':
critical++;
break;
case 'U':
urgent++;
break;
case 'N':
normal++;
break;
case 'L':
low++;
break;
}
}
printf("\n--- Patient Category Analysis ---\n");
printf("Critical Patients : %d\n", critical);
printf("Urgent Patients : %d\n", urgent);
printf("Normal Patients : %d\n", normal);
printf("Low Patients : %d\n", low);
}
Data Structures Lab
// Main Function
int main()
{
int choice;
struct patient p;
while (1)
{
printf("\n===== Emergency Room Triage System =====\n");
printf("1. Add Patient\n");
printf("2. Attend Patient\n");
printf("3. Display Queue\n");
printf("4. Analyze Categories\n");
printf("5. Exit\n");
printf("Enter choice: ");
scanf("%d", &choice);
switch (choice)
{
case 1:
printf("Enter Patient ID: ");
scanf("%d", &[Link]);
printf("Enter Patient Name: ");
scanf("%s", [Link]);
printf("Enter Age: ");
scanf("%d", &[Link]);
printf("Enter Severity (C/U/N/L): ");
scanf(" %c", &[Link]);
enqueue(p);
break;
case 2:
dequeue();
break;
Data Structures Lab
case 3:
display();
break;
case 4:
analyze();
break;
case 5:
printf("Exiting System...\n");
return 0;
default:
printf("Invalid Choice!\n");
}
}
return 0;
}
OUTPUT:
Data Structures Lab
OUTPUT: