You are on page 1of 3

NFC Institute of Engineering&Fertilizer

Research Faisalabad

Department of Electrical Engineering


Fourth Semester
Course Title:
Data Structure & Algorithms (EE-232)
Topic:
Lab Assignments
Submitted To:
Dr. Salman Arain
Submitted By:
Hafeez Ali
Roll.No:
18-ELE-43
Reg.#:
2018-UET-NFC-FD-ELECT-43
Lab.No.7
QUEUE OPERATION USING LINEAR ARRAY
Task#1
Write a function for enqueue operation.
C Function:
int enqueue(int data)
{
if (isFull()) {
return 0;
}
rear = (rear + 1) % CAPACITY;
size++;
queue[rear] = data;
return 1;
}

Task#2
Write a function for dequeue operation.
C Function:
int dequeue(int data)
{
int data = INT_MIN;
if (isEmpty()) {
return INT_MIN;
}
data = queue[front];
front = (front + 1) % CAPACITY;
size--;
return data;
}
Task#3
Write a function for display of a queue.
C Function:

void display()
{
int i;

printf("The queue elements are as follows: ");

for(i = front; i < = rear; i++){


printf("%d ", queue[i]);
}

Conclusion:
In this lab, I came to know the implementation of queue operation using
linear array and their use such as Enqueue & Dequeue Operations.
I also came to know their working and programming step by step.

You might also like