# Понятие очереди, принципы работы, примеры использование, временные сложности операций.

Очередь - специальный тип списка, в котором элементы вставляются с одного конца, называемого задним, а удаляются с другого, переднего. Список типа FIFO - First In First Out (первым вошел, первым вышел)

Пример:

```
queue = []


def insert(q, val):
    q.append(val)


def get(q):
    return q[0]


insert(queue, 1)
insert(queue, 2)
insert(queue, 3)
insert(queue, 4)
get(queue) //Вернет 1
get(queue) //Вернет 2
```

Временная сложность добавления и извлечения из очереди линейная


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://python.vkryuchkov.ru/chapter2/ponyatie_ocheredi-_printsipi_raboti-_primeri_ispol.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
