Function DeCqueue (CQ)
This Function deletes an element from circular queue.
Step 1 copying front index value to temporary variable
set data ® CQ (item [Q(front)]
Step 2 setting values
if (CQ (front) = CQ(rear))
{
set CQ (front) = – 1
set CQ(rear) = – 1
}
elseif (CQ(front) = SIZE – 1)
set CQ (front) = 0
else
set CQ(front ) ¬ CQ (front) + 1
Step 3 return value at the time of call.
return (data)
Equivalent C code is given below:
int DeCqueue (queue * CQ)
{
int data
data = CQ ® item [Q ® front];
if (CQ ® front = = CQ ® rear)
{
CQ ® front = – 1;
CQ ® rear = – 1;
}
elseif (CQ ® front = = SIZE – 1
CQ ® front = 0
else
CQ ® front = CQ ® front + 1) ...(i)
return data;
}
No comments:
Post a Comment