# Difference Between Stack and Queue

## Difference Between Stack and Queue in Tabular Form

The major difference between a Stack and a Queue is that stack is a LIFO type while Queue is FIFO type data structure. LIFO stands for Last In First Out i.e if we put data in a stack then the last entry will be processed first. While FIFO stands for First In First Out it means the first entry in a queue will be processed first.

### Comparison Chart

StackQueue
A Linear List Which allows insertion or deletion of
an element at one end only is called Stack
A Linear List Which allows insertion at one end and
deletion at another end is called a Queue
Since insertion and deletion of an element are performed at one end of the stack, the elements can only be removed in the opposite order of
insertion.
Since insertion and deletion of an element are performed at the opposite end of the queue, the elements can only be removed in the same order of
insertion.
A stack is called as Last In First Out (LIFO) ListA queue is called First In First Out (FIFO) List.
The most and least accessible elements are called
as TOP and BOTTOM of the stack
Insertion of an element is performed at the FRONT end
and deletion is performed from a REAR end
Example of the stack is arranging plates in one above
one.
Example is ordinary queue in provisional store.
Insertion operation is referred to as PUSH and
deletion operation is referred to as POP
Insertion operation is referred to as ENQUEUE and
deletion operation is referred to as DEQUEUE
Function calling in any languages uses StackTask Scheduling by Operating System uses queue
To check if a stack is empty, the following condition is used:
TOP == -1
To check if a queue is empty, the following condition is used:
FRONT == -1 || FRONT == REAR + 1
To check if a stack is full, the following condition is used:
TOP == MAX – 1
To check if a queue is full, the following condition is used:
REAR == MAX – 1
A Stack requires only one reference pointer.A Queue requires two reference pointers.

### Stack Implementations

The condition to check if a stack is empty:

```int isEmpty()
{
if(top==-1)
return 1;
else
return 0;
}```

The condition to check if a stack is full:

```int isFull()
{
if(top==MAX-1)
return 1;
else
return 0;
}```

### Queue

The condition to check if a queue is empty:

```int isEmpty()
{
if(front==-1 || front==rear+1)
return 1;
else
return 0;
}```

The condition to check if a queue is full:

```int isFull()
{
if(rear==MAX-1)
return 1;
else
return 0;
}```