Queue is a special linear list. It only allows deletion operations at the front end (front) of the table, and insertion operations at the rear end (rear) of the table. Like the stack, the queue is a linear table with restricted operations; the end where the insertion operation is performed is called the queue. The end where the deletion operation is performed is called the head of the queue; when there are no elements in the queue, it is called an empty queue.
The queue is a special linear table. The special thing is that it only allows deletion operations at the front end (front) of the table. The backend (rear) of the table performs insertion operations. Like the stack, the queue is a linear table with limited operations. The end that performs the insertion operation is called the tail of the queue, and the end that performs the deletion operation is called the head of the queue. When there are no elements in the queue, it is called an empty queue.
The data elements of the queue are also called queue elements. Inserting a queue element into the queue is called enqueuing, and deleting a queue element from the queue is called dequeuing. Because the queue only allows insertion at one end and deletion at the other end, only the element that enters the queue earliest can be deleted from the queue first, so the queue is also called a first-in-first-out (FIFO—first in first out) linear list.
Linked list implementation of queue
In the formation process of the queue, the principle of linear linked list can be used to generate a queue.
The queue based on the linked list needs to dynamically create and delete nodes, which is less efficient, but can grow dynamically.
The queue uses FIFO (first in first out). New elements (elements waiting to enter the queue) are always inserted into the end of the linked list, and when reading, they always start reading from the head of the linked list. . Each time one element is read, one element is released. The so-called dynamic creation and dynamic release. Therefore, there are no problems such as overflow. Since the linked list is indirectly formed by the structure, it is also convenient to traverse.
Basic operations of queue
(1) Initialization queue: Init_Queue(q), initial condition: queue q does not exist. Operation result: An empty queue is constructed;
(2) Queue entry operation: In_Queue(q,x), initial condition: Queue q exists. Operation result: For the existing queue q, insert an element Empty, operation result: delete the first element of the queue and return its value, the queue changes;
(4) Read the first element of the queue: Front_Queue(q,x), initial condition: queue q exists and is not empty, Operation result: Read the queue head element and return its value, the queue remains unchanged;
(5) Queue empty operation: Empty_Queue(q), initial condition: queue q exists, operation result: if q is empty Team returns 1, otherwise returns 0.
For more related knowledge, please visit
PHP Chinese websiteThe above is the detailed content of What does queue mean?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)