0% found this document useful (0 votes)
31 views3 pages

Fourth Semester Department of Electrical Engineering

The document outlines lab assignments for implementing queue operations using a linear array, including functions for enqueue, dequeue, and displaying the queue, with code examples provided for each function; the lab helped the student learn how to implement queues using arrays and understand their workings through hands-on programming of enqueue, dequeue, and display operations.

Uploaded by

Hafeez Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views3 pages

Fourth Semester Department of Electrical Engineering

The document outlines lab assignments for implementing queue operations using a linear array, including functions for enqueue, dequeue, and displaying the queue, with code examples provided for each function; the lab helped the student learn how to implement queues using arrays and understand their workings through hands-on programming of enqueue, dequeue, and display operations.

Uploaded by

Hafeez Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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