Get free ebooK with 50 must do coding Question for Product Based Companies solved
Fill the details & get ebook over email
Thank You!
We have sent the Ebook on 50 Must Do Coding Questions for Product Based Companies Solved over your email. All the best!

# Difference Between Array, Queue and Stack

Last Updated on April 26, 2023 by Abhishek Sharma

### Array:

An Array is a collection of elements which are stored in a contiguous memory. The idea is simple i.e. to store the multiple elements together. Due to which we can easily calculate the position of each element by adding the memory location of the first element i.e. name of the array.

### Queue:

A Queue is a linear data structure. Queue follows the FIFO rule i.e. First in First out. In other words we can say the element that goes in first is the element that comes out first. For Example A ticket Queue outside a cinema hall where the person enters the queue first will get the ticket first.

### Basic Operations of Queue:

Enqueue: This operation is used to Insert an element at the end of the queue.

Dequeue: This operation is used to remove and return an element from the front of the queue.

isEmpty(): This operation is used to check whether the queue is empty or not.

isFull(): This operation is used to check whether the queue is full or not.

Peek(): This operation is used to get the value of the element from the front of the queue.

### Stack:

Stack is a linear data structure in which a user can insert and delete an element from the same end which is known as a top. Stack data structure follows LIFO property i.e. Last in first out. In LIFO, the element which was inserted last will be the element which was removed first. In stack, the process of insertion is called push operation and the process of deletion of the element from the stack is known as pop. And, we can easily keep track of the last element using a pointer called top.

### Difference between Array, Stack and Queue

This article tried to discuss the Difference between array, queue and stack. Hope this blog helps you understand the concept. To practice more problems feel free to check MYCODE | Competitive Programming at Prepbytes.