figure queue of python data objects queues we now turn our attention to another linear data structure this one is called queue like stacksqueues are relatively simple and yet can be used to solve wide range of important problems what is queuea queue is an ordered collection of items where the addition of new items happens at one endcalled the "rear,and the removal of existing items occurs at the other endcommonly called the "front as an element enters the queue it starts at the rear and makes its way toward the frontwaiting until that time when it is the next element to be removed the most recently added item in the queue must wait at the end of the collection the item that has been in the collection the longest is at the front this ordering principle is sometimes called fifofirst-in first-out it is also known as "first-come first-served the simplest example of queue is the typical line that we all participate in from time to time we wait in line for moviewe wait in the check-out line at grocery storeand we wait in the cafeteria line (so that we can pop the tray stackwell-behaved linesor queuesare very restrictive in that they have only one way in and only one way out there is no jumping in the middle and no leaving before you have waited the necessary amount of time to get to the front figure shows simple queue of python data objects computer science also has common examples of queues our computer laboratory has computers networked with single printer when students want to printtheir print tasks "get in linewith all the other printing tasks that are waiting the first task in is the next to be completed if you are last in lineyou must wait for all the other tasks to print ahead of you we will explore this interesting example in more detail later in addition to printing queuesoperating systems use number of different queues to control processes within computer the scheduling of what gets done next is typically based on queuing algorithm that tries to execute programs as quickly as possible and serve as many users as it can alsoas we typesometimes keystrokes get ahead of the characters that appear on the screen this is due to the computer doing other work at that moment the keystrokes are being placed in queue-like buffer so that they can eventually be displayed on the screen in the proper order basic data structures