D Ata S Tructu Res: Chapter - 4: Queues
D Ata S Tructu Res: Chapter - 4: Queues
Chapter – 4: Queues
Asmelash Girmay
Department of Information Technology
4.1 Definition of Queue
• A queue is logically a first in first out (FIFO or first come first serve) linear
data structure.
• The concept of queue can be understood by our real-life problems.
• For example: a customer come and join in a queue to take the train ticket at the end
(rear) and the ticket is issued from the front end of queue.
• That is, the customer who arrived first will receive the ticket first.
• It means the customers are serviced in the order in which they arrive at the service
center.
• It is a homogeneous collection of elements in which new elements are
added at one end called rear, and the existing elements are deleted from
other end called front.
5
2
2. Push (10) 5. Push (70)
6
3
3. Push (3)
6. X = pop () (i.e. X=10)
7 9
- 1)
push (20)