Be able to describe and apply the following to linear queues, circular queues and priority queues:
- add an item
- remove an item
- test for an empty queue
- test for a full queue
Operation | Description |
---|---|
Add (Enqueue) | Adds a new item to the rear of the queue |
Remove (Dequeue) | Removes an item from the front of the queue |
IF Queue is FULL THEN
Error
ELSE
Queue[Queue.size + 1] = "Ian"
Queue.size += 1
END IF
IF Queue is FULL THEN
Error
ELSE
position = (Queue.size + 1) % Queue.max
Queue[position] = "Ian"
Queue.size += 1
END IF
IF Queue is FULL THEN
Error
ELSE
position = Queue.size % Queue.max
Queue[position] = null
Queue.size -= 1
END IF