Queue : Data Structure

Queue is an abstract data structure, somewhat similar to Stacks. Unlike stacks, a queue is open at both its ends. One end is always used to insert data (enqueue) and the other is used to remove data (dequeue). Queue follows First-In-First-Out methodology, i.e., the data item stored first will be accessed first.

not available

Basic Operations:

Queue operations may involve initializing or defining the queue, utilizing it, and then completely erasing it from the memory. Here we shall try to understand the basic operations associated with queues −

not available

The following steps should be taken to enqueue (insert) data into a queue −

                
            if(rear==max-1) 
"overflow"
else
arr[max++]=val

not available
                if(front<0 || front >rear) 
"underflow"
else
front++;