Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Queues | Advanced Data Structures
Algorithms and Data Structures Overview

QueuesQueues

In contrast to stack, queues operate on a FIFO (First In, First Out) basis. Therefore, the first item inserted into a queue will be the first item removed. It means that for queues, we can manipulate only the first item exclusively. The queue data structure behavior resembles the queue in real life.

Queue implementation

Queue is also an abstract data type. As well as stack, queue also defines two basic operations, insertion and deletion, which are implemented in two basic methods:

  • enqueue() - inserts an element into an end of a queue;
  • dequeue() - removes a first element from a queue.

The queue abstract data type can be implemented with the help of both the array or linked list data structure.

Basic operations time complexity

Method Array Implementation Doubly Linked List Implementation
enqueue() O(1) O(1)
dequeue() O(1) O(1)

Which data structure is commonly used to implement a queue in Python?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 2
course content

Зміст курсу

Algorithms and Data Structures Overview

QueuesQueues

In contrast to stack, queues operate on a FIFO (First In, First Out) basis. Therefore, the first item inserted into a queue will be the first item removed. It means that for queues, we can manipulate only the first item exclusively. The queue data structure behavior resembles the queue in real life.

Queue implementation

Queue is also an abstract data type. As well as stack, queue also defines two basic operations, insertion and deletion, which are implemented in two basic methods:

  • enqueue() - inserts an element into an end of a queue;
  • dequeue() - removes a first element from a queue.

The queue abstract data type can be implemented with the help of both the array or linked list data structure.

Basic operations time complexity

Method Array Implementation Doubly Linked List Implementation
enqueue() O(1) O(1)
dequeue() O(1) O(1)

Which data structure is commonly used to implement a queue in Python?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 2
some-alt