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

QUESTION

Uploaded by

skfeath.coding
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)
6 views3 pages

QUESTION

Uploaded by

skfeath.coding
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
You are on page 1/ 3

East West University

Department of Computer Science & Engineering


A/2, Jahurul Islam Avenue, Jahurul Islam City, Aftabnagar, Dhaka-1212
______________________________________________________________________
Lab Manual : 04 (Queue)
Course Code : CSE207
Course Title : Data Structure
Instructor : Dr. Maheen Islam, Associate Professor, CSE, East West University

Objective:
The objective of this lab is to give some basic concepts about QUEUE data structure.
After completion of the lab students will know:
• How to create data element in queue
• How to delete data element from queue
• How to perform different operations on queue i.e. copying, compression of string
etc.
• Different applications of queue in real life
Preliminaries:

A queue or FIFO (first in, first out) is an abstract data type that serves as a collection of
elements, with two principal operations: enqueue, the process of adding an element to
the collection.(The element is added from the rear side) and dequeue, the process of
removing the first element that was added. (The element is removed from the front
side). It can be implemented by using both array and linked list.

Queue is used when things don’t have to be processed immediately but have to be

Page 1 of 3
processed in First in First out order. This property of Queue makes it also useful in
following kind of scenarios.

1) When a resource is shared among multiple consumers. Examples include CPU


scheduling, Disk Scheduling.
2) When data is transferred asynchronously (data not necessarily received at same rate
as sent) between two processes. Examples include IO Buffers, pipes, file IO, etc.

Lab Task:
Exercise 1:
Create Queue (Enqueue)
Create queue allocates a new node for the queue. It first initializes the front and rear
pointers to null. If the queue is empty then insert new node in queue and update both
the front and rear pointer with the address of the new node and if queue is not empty
then update the rear pointer with the address of the new node

Exercise 2:
Delete node from Queue (Dequeue)
It begins by checking to make sure there are data in queue. If there are, it takes the
addresses of the data being deleted , adjust the front pointer and remove the allocated
memory space.

Exercise 3:
Print Queue
The print function will print the entire queue data.

Exercise 4:
CopyQueue
Write a program that copies the content one queue to another

Input Data Output Data


Q1: 1 2 3 4 5 Q2: 1 2 3 4 5

Page 2 of 3
Exercise 5:
Compression of string
Write a program that compresses a string by deleting all space characters in the string.
Solve the problem using Queue

Input Data Output Data


we are the students of CSE wearethestudentsofCSE

Exercise 6:
Stack to Queue Creation
Write a program that creates a Queue from a stack. After creation the top of the stack
will be the front of the queue.

Input Data Output Data


S: 1 2 3 4 5 Q: 5 4 3 2 1

Exercise 7:
Delete all Negative Integer
Write a program that will take a queue of integers and deletes all negative integers
without changing the order of the remaining elements in queue.

Input Data Output Data


Q: 1 2 -3 4 - 5 Q: 1 2 4

Page 3 of 3

You might also like