# Difference Between Array-Based Queue and List-Based Queue

## Introduction

A queue is a linear data structure that inserts and removes queue elements in a particular order. We can implement a queue in C++ by using arrays and a linked list. Both queue implementations have their benefits and uses. In this tutorial, we will differentiate the array-based Queues and List Based Queues.

## What is a Queue?

A Queue is a series of elements that uses the FIFO principle for the insertion and deletion of its elements. A queue in Computer Science resembles the queue of real life where the one who enters first in the queue, will be removed first.

The process of removing Queue data is called deQueue. The operation of adding data into the queue is called enQueue.

The Queue has two points −

• Rear − Elements in the Queue are inserted from this point.

• Front − Elements from the Queue are removed from this point.

We can implement Queue by using two approaches −

• Array-based Queue

• List-based Queue or Linked List Queue

### Array-Based Queue

A queue that uses an array for its implementation is known as an Array-based queue. It uses two pointers: Front and Rear, to represent the deletion and insertion points respectively in the Queue.

In this implementation, the array size is predefined before inserting the data. It is the simplest way to insert and delete queue data.

### List Based Queue

In a list-based queue or linked list-based queue, a linked list is used for queue implementation. Each queue node comprises two parts: one for storing data, and the other is the link part or memory part.

Each queue element is connected to the memory of the next Queue element. In list based queue there are two pointers −

• Front pointer − Represent Memory of the last queue element.

• Rear pointer − Represent memory of the first queue element.

## Difference Between Array-based Queue and List-Based Queue

S.No

Array-Based Queue

1

Complexity

It is easy to implement and carry out operations.

It is not easy to implement.

2

Searching Process

It helps in easy and fast searching.

It is slow and has difficult searching operations.

3

Queue Size

Define the Queue size at the time of its initialization.

No need to define the Queue size at the time of queue initialization.

4

Insertion and Deletion Operation

Difficult data insertion at the beginning and easy insertion at the end of the queue.

It provides easy data insertion at both Queue ends.

5

Accessing data

Random data accessing.

6

Queue Resizing

It is difficult to change the queue size.

It is easy to resize the queue.

7

Memory Usage

It consumes less memory.

It consumes more memory.

8

• It is faster and easier to implement.

• It consumes less memory.

• Randomly access the elements.

• Insertion and deletion of queue elements is easy.

• Easy to resize the Queue and no need to declare the queue size in advance.

9

• Queue resizing is difficult.

• Declare the queue size in advance.

• It is slow in processing.

• It has a complex structure and consumes more memory.

## Usage of Array-based Queue and List-Based Queue

You can implement a Queue using an array if your queue is of fixed size and no need to alter the queue size. The array-based queue is also useful in case of fast searching with less memory consumption.

Linked list-based queue implementation is useful when queue size is dynamic, and queue elements are inserted and removed multiple times. Although it consumes more memory, it is used for large-scale applications

## Conclusion

The use of array-based queues and linked list-based queues depends on the requirement. In large-scale applications array-based queue is unsuccessful, and a Linked list queue is used.

Array-based Queue uses less memory but it wastes lots of memory because after inserting an element at the rear end, some unused memory remains before the first element.