What is a queue?

Source: Internet
Author: User

Similar to linked lists and stacks, queues are also the structures that store data. The order in which the data enters the queue in the queue is important, in general, the queue is a group of people or things in the order in which they wait to receive services or processing.

Definition: queues , also known as queue, are linear tables that are first in, out (FIFO, first-in-first-out). In a specific application, it is usually implemented with a linked list or an array. Queues allow insertions only on the back end (known as rear) and delete operations on the front end (known as front).

As with the stack, there are two operations, the incoming (EnQueue) and the outbound (DeQueue), for the empty queue for the outbound operation will cause the next overflow (underfLow), The corresponding heap full queue is queued for incoming operations to occur on overflow. See the example diagram below:

How does the queue work?

A row of people in front of the desk explained the concept of the queue. When we have to accept the service can only be in the last side of the queue, the front of the queue is the person who is or will receive the service, when he walked out of the queue is to accept the service.

When the queue is receiving service, we move forward slowly, because the people who have served are out of the queue. Finally, we arrived at the head of the team and received service. This rule is useful when we need to maintain the order of incoming customers.

Direct application:

  • The operating system's dispatch job (the same priority tasks come in order).
  • Simulate real-world queues (such as queues at the ticket booths).
  • Multi-channel programming.
  • Asynchronous data Transfer (file I/O, pipes, sockets).
  • The waiting time for the call center customer.
  • The decision of the supermarket's cash saving amount.

Indirect applications:

  • The data structure of the auxiliary algorithm.
  • The composition of other data structures.

What is a queue?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.