Lecture 5
Lecture 5
⚫ Queue follows the First In First Out (FIFO) rule - the item that
goes in first is the item that comes out first.
⚫ Peek: Get the value of the front of the queue without removing it
Working Procedure
Enqueue Operation
⚫ Check if the queue is full
⚫ For the first element, set the value of FRONT to 0
⚫ Increase the REAR index by 1
⚫ Add the new element in the position pointed to by REAR
Dequeue Operation
⚫ Check if the queue is empty
⚫ Return the value pointed by FRONT
⚫ Increase the FRONT index by 1
⚫ For the last element, reset the values of FRONT and REAR to -1
Working Procedure
Example
⚫ Call Center phone systems use Queues to hold people calling them
in order.
Types of Queue
⚫ Simple Queue
⚫ Circular Queue
⚫ Priority Queue