A circular queue stores requests in fixed slots and wraps an advancing index from the last slot back to slot 0. This implementation uses all four slots, numbered 0 through 3. The variable head identifies the next request to remove, tail identifies the next insertion slot, and count records the number of waiting requests. Each successful enqueue advances tail; each successful dequeue advances head. A rejected operation changes nothing.
Initially, head = 3, tail = 3, and count = 4. The physical storage is shown below. The initial logical order from front to rear is R7, R8, R9, R10.
Select every correct statement. Evaluate each statement independently from this initial state. A full queue rejects an enqueue rather than overwriting a waiting request.
After one dequeue followed by enqueuing R11, both indices are 0, and the logical waiting order is R8, R9, R10, R11.
An immediate attempt to enqueue R11 is rejected because the count equals the capacity, even though the head and tail indices are equal.
Because head equals tail, the queue is empty, so inserting R11 into slot 3 preserves all requests that are waiting.
Copying occupied slots to the same indices in eight-slot storage, retaining head = 3 and count = 4, preserves removal order using wraparound at 8.
Unlock full course notes by signing up
Size a queue for its busiest moment
A server's queue initially holds 7 waiting requests. Its capacity is the maximum number of waiting requests it can store. Requests already removed for processing do not occupy queue space.
The following batches occur in the stated order. Each batch finishes before the next begins, and there are no other arrivals or removals:
Enqueue 8 requests.
Order the steps of a linked-list dequeue
A queue is implemented with singly linked nodes. It keeps a head reference to the oldest node and a tail reference to the newest node, and both are null when the queue is empty. Put the steps of a correct dequeue operation in the order they must run, so that the oldest value is returned and both references remain valid afterwards, even when the queue held exactly one element.
Compute circular-array indices after wraparound
A print server stores waiting jobs in a circular array queue with capacity 8, using indices 0 to 7. It tracks front, the index of the oldest job, and size, the number of jobs stored. The next enqueue writes to index (front+size) mod 8(\text{front} + \text{size}) \bmod 8(front+size)mod8, and a dequeue advances front by one position, wrapping from 7 back to 0.
At the start, front is 5 and size is 3. The server then performs four enqueue operations followed by two dequeue operations, and none of them fails.
Give each of the following as a whole number: