What is a Queue?
💻 coding

What is a Queue?

1 min read 248 words
1 min read
ShareWhatsAppPost on X
  • 1A queue is a data structure that follows the First In First Out (FIFO) principle for data management.
  • 2Main operations of a queue include enQueue for insertion and deQueue for deletion of elements.
  • 3Queues are used in various applications like job scheduling, real-world line simulations, and managing waiting times.

AI-generated summary · May not capture all nuances

Key Insight
AskGif

"A queue is a data structure that follows the First In First Out (FIFO) principle for data management."

What is a Queue?

A queue is a data structure used for storing data (similar to Linked Lists and Stacks). In a queue, the order in which data arrives is important. In general, a queue is a line of people or things waiting to be served in sequential order starting at the beginning of the line or sequence.

A queue is an ordered list in which insertions are done at one end (rear) and deletions are done at other ends (front). The first element to be inserted is the first one to be deleted. Hence, it is called First In First Out (FIFO) or Last In Last Out (LILO) list.

Queue ADT

The following operations make a queue an ADT. Insertions and deletions in a queue must follow the FIFO scheme. For simplicity, we assume the elements are integers.

Main Queue Operations:

- enQueue(int data): Inserts an element at the end of the queue

- int deQueue(): Removes and returns the element at the front of the queue.

Applications:

- Operating systems schedule jobs (with equal priority) in the order of arrival (e.e a print queue).

- Simulation of real-world queues such as lines at a ticket counter, or any other first-come first-served scenario requires a queue.

- Multiprogramming.

- Asynchronous data transfer (file IO, pipes, sockets).

- Waiting times for a customer at a call center.

- Determining the number of cashiers to have at a supermarket.

source: Data Structures and Algorithms Made Easy in Java ( By Narasimha Karumanchi )

Enjoyed this article?

Share it with someone who'd find it useful.

ShareWhatsAppPost on X

AskGif

Published on 8 August 2018 · 1 min read · 248 words

Part of AskGif Blog · coding

You might also like