Page 143 - DCAP407_DATA_STRUCTURE
P. 143
Data Structure
Figure 8.4 depicts inserting and deleting an element from deque.
Figure 8.4: Inserting and Deleting an Element from Deque
Program for the Insertion and Deletion of an Element in a Dequeue.
#include<stdio.h>
#include<conio.h>
#define SIZE 5
int Q_F(int R)
{
return (R==SIZE-1)?1:0;
}
int Q_E(int F, int R)
{
return(F>R)?1:0;
}
void front_insert(int num, int Q[], int *F, int *R)
{
if(*F==0 || *R==-1)
{
Q[++(*r)]=item;
return;
}
if(*F!=0)
{
Q[--(*F)]=item;
return;
136 LOVELY PROFESSIONAL UNIVERSITY