Queue
Queue
Dr.M.Praneesh
Professor
Sri Ramakrishna College of Arts & Science
Stack and Queue / Slide 2
Queue ADT
Like a stack, a queue is also a list. However,
with a queue, insertion is done at one end,
while deletion is performed at the other end.
Accessing the elements of queues follows a
First In, First Out (FIFO) order.
Like customers standing in a check-out line in a
store, the first customer in is the first customer
served.
Stack and Queue / Slide 3
Remove Insert
(Dequeue) front rear (Enqueue)
Stack and Queue / Slide 5
3 3 6 3 6 9
Create Queue
Queue(int size = 10)
Allocate a queue array of size. By default, size = 10.
front is set to 0, pointing to the first element of the
array
rear is set to -1. The queue is empty initially.
Queue::Queue(int size /* = 10 */) {
values = new double[size];
maxSize = size;
front = 0;
rear = -1;
counter = 0;
}
Stack and Queue / Slide 7
Insert
Delete
Thank You……….