0% found this document useful (0 votes)
11 views2 pages

Queues

The Queue data structure operates on a FIFO principle, allowing data to be added at one end and removed from the other. Various types of queues exist, including input/output restricted queues, circular queues, and double-ended queues, each with specific operations like enqueue, dequeue, and peek. Queues can be implemented using arrays or linked lists, each having its own advantages and disadvantages, and are commonly used in applications such as call center ticketing systems and food ordering systems.

Uploaded by

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

Queues

The Queue data structure operates on a FIFO principle, allowing data to be added at one end and removed from the other. Various types of queues exist, including input/output restricted queues, circular queues, and double-ended queues, each with specific operations like enqueue, dequeue, and peek. Queues can be implemented using arrays or linked lists, each having its own advantages and disadvantages, and are commonly used in applications such as call center ticketing systems and food ordering systems.

Uploaded by

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

The Queue data structure is used for storing and managing data in a specific order.

Queues follow
the FIFO (First In First Out) principle, where the first element that’s added to the queue is the first
one to be removed. Queues are used in many algorithms and applications because of their simplicity
and efficiency in managing the data flow.

A queue is a linear data structure that is open at both ends, because of this, additions to the are made
at one end of the queue, and deletions are made at the other end of the queue. The first entry is
sometimes referred to as the head, and the last entry is sometimes referred to as the tail.

The difference between stacks and queues is in removing. In a stack we remove the item the most
recently added; in a queue, we remove the item the least recently added

What are the characteristics of Queues?

➢ They can store more than one type of data


➢ We can access both ends
➢ They are fast and flexible

What types of Queues are there?

➢ Input Restricted Queue – In this type, we can only input to end of the queue, but we can
delete from any end of the queue
➢ Output Restricted Queue – In this type, we can input to any end of the queue, but we can
only output from one end
➢ Circular queue: In this type, the last element is connected to the first element
➢ Double-ended queue – In this type, both, insertion and deletion can be performed from both
ends

What operations are performed on Queues?

➢ Enqueue – Inserts an element to the end of the queue

➢ Dequeue– Deletes the first elements from the queue

➢ Peek – Returns the element at the front of the queue

➢ Rear – This operation returns the element at the rear end

➢ isFull – Returns true or false depending on whether the queue is full or not
➢ isNull – Returns true or false depending on whether the queue is empty or not

Some real-world applications of Queues


➢ Call centre ticketing systems
➢ Food ordering systems/applications

Implementation of Queues

Just like Stacks, Queues can also be implemented by arrays and linked lists
Array Implementation of Queues – In order to implement queues, we need to keep two indexes in
mind, the front index and the rear index, the indexes are incremented in a circular manner

To do this, we need to first check if the queue is full or not, if its full its considered an overflow and
we cannot proceed any further so we exit the program. If it isn’t empty we return the element at the
head and then increment the head

Advantages of array implementation

➢ Easy to implement
➢ Large amounts of data can managed efficiently
➢ Insertion and deletion operations are performed with ease because of the FIFO principle

Disadvantages of array implementation

➢ Arrays are static


➢ An influx of enqueue and dequeue operations can cause problems result in the inability to
make any more insertions or deletions
➢ The size of the queue would have to be defined beforehand

Advantages of linked list implementation

➢ Dynamic size
➢ Ease of insertion and deletion operations
➢ Efficient memory utilisation – linked lists only assign memory to elements they contain

Disadvantages of linked list implementation

➢ Memory overhead – nodes require extra memory in order to store the pointers, this results in
higher memory usage
➢ No random access
➢ Slower operations – the enqueue and dequeue operations are slower in linked lists because
we need to dynamically allocate memory

Advantages of Queues

➢ Useful when a service is used by multiple users

Disadvantages of Queues

➢ Operations in between elements are time consuming


➢ Maximum size of a Queue has to be defined before, in case of array implementation

You might also like