Queues Flashcards
order acronym ?
FIFO - first in first out
4 key operators
Enqueue - remove item from the rear
Dequeue - remove item from the front
IsEmpty - check if the queue is empty
IsFull - check if the queue is full
the three queue implementations?
Linear Queue
Circular Queue
Priority Queue
Linear Queue
implemented with a fixed size array
dequeuing/enqueueing - very process intensive
front and rear pointers used to indicate which range of index values are being used.
empty queue detected when rearPointer = frontPointer = -1
full queue when rearPointer = maxSize - 1
Circular Queue
reuses free spaces at the front of the queues that have been “freed”
pointers increment by 1 in a loop - equation for it –> front = (front + 1) MOD (maxSize)
rear = (rear + 1) MOD (maxSize)
full queue when size = maxSize
empty queue when size = 0
Priority Queue
some items are allowed to ‘jump’ the queue
type of queue used when items arriving have some type of priority associated with them