0% found this document useful (0 votes)
19 views

What Is Queue

A queue is a data structure that follows the First-In-First-Out (FIFO) principle, where elements are added to the back of the queue and removed from the front. Key characteristics include enqueue to add an element to the back, dequeue to remove from the front, and peek to view the front element without removing. Queues are useful when tasks must be processed in the order received, like a print queue that prints documents in the submitted order.

Uploaded by

Abdul Basit Awan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

What Is Queue

A queue is a data structure that follows the First-In-First-Out (FIFO) principle, where elements are added to the back of the queue and removed from the front. Key characteristics include enqueue to add an element to the back, dequeue to remove from the front, and peek to view the front element without removing. Queues are useful when tasks must be processed in the order received, like a print queue that prints documents in the submitted order.

Uploaded by

Abdul Basit Awan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

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

It's a collection of
elements where elements are added to the back, or "rear," of the queue, and removed from the
front, or "head," of the queue. In other words, the element that has been in the queue the longest
is the first one to be removed.

Queues are used in computer science and programming for various purposes, such as managing
tasks in a sequential order, scheduling processes in operating systems, and implementing
algorithms like breadth-first search in graph traversal. Here are some key characteristics and
operations associated with queues:

1. Enqueue: Adding an element to the back of the queue is called "enqueue" or "push."
2. Dequeue: Removing an element from the front of the queue is called "dequeue" or "pop."
3. Peek: Viewing the element at the front of the queue without removing it is called "peek"
or "front."
4. Empty Queue: A queue with no elements is often referred to as an "empty queue."
5. Size: The number of elements in the queue is the "size" of the queue.

Queues are particularly useful in scenarios where tasks or data must be processed in the order
they were received. For example, in a print queue, print jobs are processed in the order they are
sent to the printer, ensuring that the first document submitted will be the first to be printed.

Queues can be implemented using various data structures, such as arrays or linked lists, and there
are different variations, like priority queues, which assign priorities to elements and process them
based on their priority levels, while still following the basic queue principle.

You might also like