Chapter 14 Queues
What are the five basic operations on a queue?
Enqueue: adds an element to the end of the queue Dequeue: removed an element from the front of a queue First: returns a reference to the element at the front of the queue isEmpty: returns true if queue is empty
Queue
A linear collection whose elements are added on one end and removed from the other
Repeating key
A list of integer values used to shift letters by varying amounts in an improved version of a Caesar cipher
What is the difference between a queue and a stack?
A queue is a FIFO collection, whereas a stack is a LIFO collection.
Enqueue
A queue operation in which an element is added to the rear of the queue
Dequeue
A queue operation in which an element is removed from the front of the queue
Circular array
An array that is treated as circular, meaning that incrementing the last index value in the array wraps around back to the first element
Which implementation has the worst SPACE complexity?
Both of the array implementations waste space for unfilled elements in the array. The linked implementations uses more space per element stored.
Which implementation has the worst TIME complexity?
The noncircular array implementation with an O(n) dequeue or enqueue operation has the worst time complexity.
Is it possible for the head and tail references in a linked implementation to be equal?
Yes: when the queue is empty (head and tail are null), and when there is only one element on the queue
Is it possible for the front and rear references in a circular array implementation to be equal?
Yes: when the queue is empty, and when the queue is full
What are some of the other operations that might be implemented for a queue?
makeEmpty(), destroy(), full()