If we keep pointers to both the first and last nodes of the list, we can add a node at either end in constant time. However, while we can remove the first node in the list in constant time, removing the last node requires first locating the previous node, which takes time proportional to the length of the list. Therefore, we should choose to make the end of the list be the rear of the queue, and the front of the list be the front of the queue. On the other hand, the space used for a linked list is always proportional to the number of items in the list. This is because when the arary is full, a new array must be allocated and the values must be copied.
Queues are useful for many simulations, and are also used for some operations on graphs and trees.
Method reverseQ should use a Stack to reverse the order of the items in its Queue parameter.