Queue
Queue
Service Process
Characteristics of
queuing system
Queue Discipline
Nos of Servers
System Capacity
Queue Representation:
Array Representation of Queue:
■ Like stacks, Queues can also be represented in an array: In this representation, the Queue is
implemented using the array. Variables used in this case are
■ Queue: the name of the array storing queue elements.
■ Front: the index where the first element is stored in the array representing the queue.
■ Rear: the index where the last element is stored in an array representing the queue
Array representation of queue: C & C++
// Creating an empty queue // Creating an empty queue
// decrement rear
rear--;
}
front(): C & C++
// Function to get front of queue // Function to get front of queue
int front(struct Queue* queue) int front(Queue* queue)
{ {
if (isempty(queue)) if (isempty(queue))
return INT_MIN; return INT_MIN;
return queue->arr[queue- return queue->arr[queue->front];
>front]; }
}
return rearElement;
}
isEmpty() : C & C++
// This function will check whether
// Queue is empty when size is 0 // the queue is empty or not:
bool isEmpty(struct Queue* queue) bool isEmpty()
{ {
return (queue->size == 0); if (front == -1)
} return true;
else
return false;
}