Page 183 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 183
Fundamentals of Data Structures
Notes else
{
q-> head-> left =dcons(info, NULL, NULL);
q->head-> left-> right = q->head;
q->head = q->head ->left;
}
}
eq_back(dq q, void *info)
{
if (dq_empty(q))
q->head = q->tail = dcons(info, NULL, NULL)
else
{
q-> tail-> right =dcons(info, NULL, NULL);
q->tail-> right-> left = q->tail;
q ->tail = q->tail->right;
}
}
dq_front(dq q)
{
if dq is not empty
{
dq tp = q-> head;
void *info = tp->info;
q ->head = q->head->right;
free(tp);
if (q->head == NULL)
q->tail = NULL;
else
q->head->left = NULL;
return info;
}
}
dq_back(dq q)
{
if (q!=NULL)
{
dq tp = q->tail;
*info = tp->info;
q->tail = q->tail->left;
free(tp);
if (q->tail == NULL)
176 LOVELY PROFESSIONAL UNIVERSITY