Difference between Array, Queue and Stack
Last Updated :
16 Jul, 2020
Array:
An
Array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together. This makes it easier to calculate the position of each element by simply adding an offset to a base value, i.e., the memory location of the first element of the array (generally denoted by the name of the array).
The diagrammatic representation of the Array is given below:
Queue:
A
Queue is a linear structure that follows a particular order in which the operations are performed. The order is
First In First Out (FIFO). A good example of a queue is any queue of consumers for a resource where the consumer that came first is served first. 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.
The diagrammatic representation of the Queue is given below:
Stack:
A
Stack is a linear data structure in which elements can be inserted and deleted only from one side of the list, called the
top. A stack follows the
LIFO (Last In First Out) principle, i.e., the element inserted at the last is the first element to come out. The insertion of an element into the stack is called
push operation, and the deletion of an element from the stack is called
pop operation. In stack, we always keep track of the last element present in the list with a pointer called
top.
The diagrammatic representation of stack is given below:

Below is the tabular representation of the difference between Array, Stack, and Queue:
Queues | Array | Stack |
---|
Queues are based on the FIFO principle, i.e., the element inserted at the first, is the first element to come out of the list. | In the array the elements belong to indexes, i.e., if you want to get into the fourth element you have to write the variable name with its index or location within the square bracket eg arr[4] | Stacks are based on the LIFO principle, i.e., the element inserted at the last, is the first element to come out of the list. |
Insertion and deletion in Queues takes place only from rear and front respectively. | Insertion and deletion in array can be done at any index in the array. | Insertion and deletion in stacks take place only from one end of the list called the top. |
Queue has a dynamic and fixed size. | Array has a fixed size. | Stack has a dynamic and fixed size. |
Queue can contain elements of different data type. | Array contains elements of same data type. | The stack can contain elements of the different data types. |
Different types of Queues are circular queue, priority queue, doubly ended queue | Different types of Arrays are 1D, 2D, etc | Stack has only one type. |
Similar Reads
Difference between Stack and Array Stack: A stack is a linear data structure in which elements can be inserted and deleted only from one side of the list, called the top. A stack follows the LIFO (Last In First Out) principle, i.e., the element inserted at the last is the first element to come out. The insertion of an element into a
3 min read
Difference between Heaps and Sorted Array 1. Heap:A heap is a tree based data structure in which tree should be almost complete. It is of two types i.e. max and min heap. Max heap: In max heap, if p is the parent and c is its child, then for every parent p the value of it is greater than or equal to the value of cMin heap In min heap, if p
4 min read
Difference between Stack and Tree Stack: A Stack is a linear data structure in which elements can be inserted and deleted only from one side of the list, called the top. Insertion is called push operation and deletion is called pop operation in case of the stack. The order of insertion and deletion may be LIFO(Last In First Out) i.e
2 min read
Difference Between Stack and Queue Data Structures In computer science, data structures are fundamental concepts that are crucial for organizing and storing data efficiently. Among the various data structures, stacks and queues are two of the most basic yet essential structures used in programming and algorithm design. Despite their simplicity, they
4 min read
What is the difference between lists and arrays? In programming, lists and arrays are data structures used to organize and store data. Both have their unique features and purposes. Lists are dynamic and flexible, allowing for easy resizing during runtime, while arrays are static with a fixed size. This difference impacts memory usage and performan
8 min read