Course Data Structures Essentials

Queue

Course's Page 10 min Text by
User Image
Diego Rangel

Hello again ๐Ÿ˜ƒ. In this class, you will learn about Queue and its main functions.

The class is divided as follows:

  • Introduction
  • When to use a Queue?
  • Queue in C++
  • Queue in Python

Introduction

Imagine a situation where we need to maintain an order in which the elements are inserted and that we should present them in the order in which they were inserted. In this kind of situation, it is common to use a Queue.

The Queue is a type of structure that presents a different access policy than the List. Instead of modifying the Queue in any position, you can only access its first element and insert elements at the end of the Queue. This type of access is known as FIFO (First-In-Fist-Out), that is, the first one to leave the Queue is the first one that entered.

When to use a Queue?

The Queue structure has several practical applications such as:

  • Managing requests in a single shared resource such as a printer or scheduling CPU tasks.
  • Call Center uses Queues to hold callers on a request until a service representative is available.