Page 187 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 187
Fundamentals of Data Structures Balraj Kumar, Lovely Professional University
Notes Unit 11: Operations and Applications of Queues
CONTENTS
Objectives
Introduction
11.1 Operations on Queues
11.1.1 Enqueue Operation
11.1.2 Dequeue Operation
11.2 Applications of Queues
11.3 Summary
11.4 Keywords
11.5 Review Questions
11.6 Further Readings
Objectives
After studying this unit, you will be able to:
Discuss various operations on queues
Explain Enqueue and Dequeue operation
Discuss applications of queues
Introduction
The word “queue” is like the queue of customers at a counter for any service, in which customers
are dealt with in the order in which they arrive, i.e. first in first out (FIFO) order. In most cases,
the first customer in the queue is the first to be served. As pointed out earlier, Abstract Data
Types describe the properties of a structure without specifying an implementation in any way.
Thus, an algorithm which works with a “queue” data structure will work wherever it is
implemented. Different implementations are usually of different efficiencies. In this unit, we
will discuss operations on queues. Also, we will discuss various applications of queues.
11.1 Operations on Queues
Queue is a data structure that maintain “First In First Out” (FIFO) order. And can be viewed as
people queueing up to buy a ticket. In programming, queue is usually used as a data structure
for BFS (Breadth First Search).
In multiuser system, there will be request from different users for CPU time. The operating
system puts them in queue and they are disposed on FIFO(First In, First Out) basic. We will
discuss the queue data structure and the operations that it allows in this section. Similar to stack
operations, operations that can be carried out In a queue are:
Create a queue.
Check whether a queue is empty (Is empty): Checks whether the queue is empty. (If Is
empty is true, then the addition of an item is possible. If this is false, then acknowledge
with the message “Queue is empty”).
180 LOVELY PROFESSIONAL UNIVERSITY