2. Dynamically Linked Queues
• Linked Queue
int MAX_QUEUES 10; /* maximum number of stacks */
Class Queue{
element item;
Queue link;
}
Queue front[MAX_QUEUES], rear[MAX_QUEUES];
3. Dynamically Linked
Queues(Cont’d)
• Add to the rear of a linked queue
void addq(Element item){
Queue temp = new Queue();
if(IS_FULL(temp)){
print(“The memory is full”);
exit(1);
}
temp.item = item;
temp.link = null;
if(front != null) {
rear.link = temp;
∙∙∙∙ (a)
} else {
front = temp; ∙∙∙∙ (b)
}
rear = temp;
}