Queues

A queue is an ordered collection of elements as shown in Figure 1.4(b) in Chapter 1Getting 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 ...

Get R Data Structures and Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.