Queues
A queue is an ordered collection of elements as shown in Figure 1.4(b) in Chapter 1, Getting Started. In queues, addition is restricted to one end, referred to as rear, and deletion is restricted to another end, which is known as the front. Queues follow the First In First Out (FIFO) principle, also known as the first-come-first-served approach. Thus, an element pushed into a queue will wait until all the elements in front are removed. The queue data structure can be applied to any shared resources scenario. For example, in a network printer case where multiple users are sending printing jobs to the same printer, the jobs are arranged in a queue, and are processed in order of arrival. Another example of a queue from our day-to-day life is a shop counter serving multiple people-they use a queue for serving and, thus, follow the FIFO principle in serving the people in the queue. Also, databases accessed by multiple departments/users also use queues to process their queries on...