0% found this document useful (0 votes)
3 views2 pages

Queue Task

Uploaded by

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

Queue Task

Uploaded by

emank1892
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

THE SUPERIOR UNIVERSITY LAHORE

(Spring 2024)

Faculty of Computer Science and Information Technology Section: BSCS


Subject: Data Structures & Algorithms-Lab Total Marks: -
Instructor: Ahmad Hassan

C++ Queue. A queue stores multiple elements in a specific order, called FIFO. FIFO
stands for First in, First Out. To visualize FIFO, think of a queue as people standing
in line in a supermarket. The first person to stand in line is also the first who can
pay and leave the supermarket.
------------------------------------------------------------------------------------------------------------------------------------------

Lab Tasks
Lab Task: Implementing Queue Using Arrays

Task 1: Implement Queue Using Arrays

1. Initialize the Queue


o Define a class Queue with a maximum size, an empty list.
2. Create isEmpty Function
o Define a method isEmpty to check if the Queue is empty.
3. Create isFull Function
o Define a method isFull to check if the Queue is full.
4. Create Enqueue () Function
o Define a method Enqueue to add an element from the rear.
5. Create Dequeue () Function
o Define a method Dequeue to remove and return the Front element of the Queue.
6. Create display Function
o Define a method display to print all elements in the Queue.
7. Create search Function
o Define a method search to find the position of an element in the Queue.

Task 2: Implement Queue Using Linked List

1. Initialize the Queue

 Define a `Queue` class using a linked list with front and rear pointers.

2. Create isEmpty Function


 Define a method `isEmpty` to check if the queue is empty.

3. Create Enqueue() Function

 Define a method `enqueue` to add an element to the rear of the queue.

4. Create Dequeue() Function

 Define a method `dequeue` to remove and return the front element of the queue.

5. Create display Function

 Define a method `display` to print all elements in the queue

6. Create search Function

Define a method `search` to find the position of an element in the queue.

You might also like