Skip to content

Course home

Data structures

Data structures

EasyMedium
12345678910111213
Question 5

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:

  • front\text{front}front points to the element currently at the front of the queue.
  • rear\text{rear}rear points to the element currently at the rear of the queue.

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?

A

front=6\text{front} = 6front=6, rear=2\text{rear} = 2rear=2

B

front=2\text{front} = 2front=2, rear=2\text{rear} = 2rear=2

C

front=6\text{front} = 6front=6, rear=12\text{rear} = 12rear=12

D

front=2\text{front} = 2front=2, rear=12\text{rear} = 12rear=12

Markscheme

Data structures Questions

  1. GCSE
  2. /Computer Science
  3. /Data structures

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.

Question bank