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

bookQueue

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.
question mark

What statement is true?

Select the correct answer

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 2

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

Suggested prompts:

Ställ mig frågor om detta ämne

Sammanfatta detta kapitel

Visa verkliga exempel

Awesome!

Completion rate improved to 4.35

bookQueue

Svep för att visa menyn

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.
question mark

What statement is true?

Select the correct answer

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 2
some-alt