Page 196 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 196
Unit 11: Operations and Applications of Queues
Notes
temp = *front;
element = temp->x;
free(*front);
*front = *rear = NULL;
}
else
{
temp = *front;
element = temp->x;
temp = temp->next;
free(*front);
*front = temp;
}
return(element);
}//dequeue
void display(node *front)
{
node *current;
current = front;
printf("Front =%u",front);
while(current != NULL)
{
printf("Data = %d, Next = %u",current->x,current->next);
current = current->next;
}//while
}//display
Question
Write a C program to insert and delete elements from a Queue.
Source: http://datastructuresinterview.blogspot.in/2013/02/c-program-to-enqueue-and-dequeue-
using.html
11.3 Summary
Is empty operation checks whether the queue is empty. (If Is empty is true, then the
addition of an item is possible.
Is full operation checks whether the queue is full.
Enqueue operation is used to add an item to the queue at the rear end. So, the head of the
queue will be now occupied with an item currently added in the queue.
When the first element is inserted the queue is initialized to zero.
Dequeue operation is used to remove an item from the queue at the front end.
The dequeue operation continues until the queue is reaching its last element.
LOVELY PROFESSIONAL UNIVERSITY 189