Q_1 : Explain how the state of a queue changes during several consecutive insert
ID: 3858876 • Letter: Q
Question
Q_1: Explain how the state of a queue changes during several consecutive insertion and extraction operations
Q-2: Explain how the state of a stack changes during several consecutive insertion and extraction operations.
Q_3: Explain how the state of a double-ended queue changes during several consecutive insertion and extraction operations in any of its ends.
Q_4: Explain why the implementation of a queue using a linked list requires insertion and extraction operations to be performed in different ends of the list.
Q_5: Explain why, to implement a queue using a linked list, it is recommended to keep a reference to the last node (tail) of the list.
Q_6: Explain why, to implement a queue using a linked list, it is recommended to extract nodes from the top of the list and insert nodes at the tail of the list.
Explanation / Answer
Q-1- The queue is the thing where the policy called "First come First serve" is used.The cconsecutive insertion of the elements in the queue may leads to the overflowing of queue.Since there will be specific size for the queue.
Q-2- The state of the stack changes to stackoverflow where there will be particular size for the stack. when the push in the stack is done without performing any pop option so the state of the stack becomes overflowing.
Q-3-There will be certain size for the double ended queue.But in double ended queue the insertion and deletion can be done in both end so that the insertion can happen on both the end but it happens consectively there will be overflow.
Q-4-Queue implementation is done by using linked list.Since in the queue nothing but the first reached must be served first so let us assume head part and tail part.The element is inserted through tail and the element in the front end is served first.
Q-5-Last node tail must be referenced since we know that the tail element is used for queuing the next element and so that keep traking of the tail is necessary.
Q-6- To implement queue the insertion must be done tail of the node while the front element is dequeued since first element is the queue must be served first which is the concept of the Queue