A circular queue of capacity 5 is implemented using a 0-indexed array of size 5. The queue uses two pointers:
Initially, the queue is empty, with front=0\text{front} = 0front=0 and rear=4\text{rear} = 4rear=4.
The operations to enqueue and dequeue are defined as follows:
The following sequence of operations is performed on the empty queue:
Which of the following correctly identifies the final values of front\text{front}front and rear\text{rear}rear, and the sequence of active elements in the queue (from front to rear)?
front=2\text{front} = 2front=2, rear=0\text{rear} = 0rear=0; active elements = [’C’,’D’,’E’,’F’][\text{'C'}, \text{'D'}, \text{'E'}, \text{'F'}][’C’,’D’,’E’,’F’]
front=1\text{front} = 1front=1, rear=0\text{rear} = 0rear=0; active elements = [’B’,’C’,’D’,’E’,’F’][\text{'B'}, \text{'C'}, \text{'D'}, \text{'E'}, \text{'F'}][’B’,’C’,’D’,’E’,’F’]
front=2\text{front} = 2front=2, rear=4\text{rear} = 4rear=4; active elements = [’C’,’D’,’E’][\text{'C'}, \text{'D'}, \text{'E'}][’C’,’D’,’E’]
front=0\text{front} = 0front=0, rear=3\text{rear} = 3rear=3; active elements = [’F’,’E’,’D’,’C’][\text{'F'}, \text{'E'}, \text{'D'}, \text{'C'}][’F’,’E’,’D’,’C’]
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.