A circular queue of capacity N=10N = 10N=10 is implemented using a 1D array with indices 0 to 9. The queue pointers front\text{front}front and rear\text{rear}rear are defined as follows:
When an item is dequeued, the item at front\text{front}front is removed, and then front\text{front}front is updated:
front=(front+1)(mod10) \text{front} = (\text{front} + 1) \pmod{10} front=(front+1)(mod10)When an item is enqueued, rear\text{rear}rear is first updated:
rear=(rear+1)(mod10) \text{rear} = (\text{rear} + 1) \pmod{10} rear=(rear+1)(mod10)and the new item is then stored at this index.
Initially, the queue has front=4\text{front} = 4front=4 and rear=9\text{rear} = 9rear=9.
If two items are dequeued and then three items are enqueued, what are the new values of front\text{front}front and rear\text{rear}rear?
front=6\text{front} = 6front=6, rear=2\text{rear} = 2rear=2
front=2\text{front} = 2front=2, rear=2\text{rear} = 2rear=2
front=6\text{front} = 6front=6, rear=12\text{rear} = 12rear=12
front=2\text{front} = 2front=2, rear=12\text{rear} = 12rear=12
36 exam-style questions on AQA GCSE Computer Science Data structures. Each one has a worked solution and a mark scheme showing where the marks go.