Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Queue | Data Structures Part I
Data Structure & Algorithms PART I
course content

Conteúdo do Curso

Data Structure & Algorithms PART I

Data Structure & Algorithms PART I

1. Introduction to ADS
2. Data Structures Part I
3. Trees Part I
4. Trees Part II

Queue

OperationBest Time ComplexityAverage Time ComplexityWorst Time ComplexityMemory Complexity
SearchO(1)O(n)O(n)O(1)
InsertionO(1)O(1)O(1)O(1)
DeletionO(1)O(1)O(1)O(1)

FIFO - first input, the first output.

Every day we go shopping. After choosing all products, we need, we go to the box office to pay for our purchases. And there, near the box office, we will meet other people who also decided to go shopping.

In computer programming, the queue is so ideal that the first person in the queue leaves the queue only if the last new customer has become a part of the queue.

The same in the data structure queue.

Enqueue is the process when the new customer becomes the last person in the queue. The process when the first customer leaves the queue is called dequeue.

The problem with the data structure queue is that it can be full. For example, only 10 people can stay near the box office while the rest of the customers must wait until there will be some empty place for them. In computer programming, we can check if the queue isEmpty or IsFull.

Advantage:

  • Slight saving of memory is possible.

Disadvantage:

  • The array size limits the maximum number of elements in the queue.

What statement is true?

Selecione algumas respostas corretas

Tudo estava claro?

Seção 2. Capítulo 2
We're sorry to hear that something went wrong. What happened?
some-alt