The diagram represents a queue Abstract Data Type (ADT). The organisation of this queue may be summarised as follows: • The FrontOfQueue pointer points to the next data item to be removed. • The EndOfQueue pointer points to the last data item added. [Figure showing Queue with elements D3, D4, D1, D2, D5 and pointers FrontOfQueue and EndOfQueue] The queue is implemented using three variables and a 1D array of eight elements as shown. The variable NumItems stores the number of items in the queue. The pointer variables store indices (index numbers) of the array.
- (a)Complete the diagram to represent the state of the queue as shown above. Index 1 2 3 4 5 6 7 8 Array Variable FrontOfQueue EndOfQueue NumItems 5[3]
- (b)A module AddTo() will add a value to the queue by manipulating the array and variables in part (a). The queue implementation is circular. When pointers reach the end of the queue, they will 'wrap around' to the beginning. Before a value can be added to the queue, it is necessary to check the queue is not full. The algorithm to add a value to the queue is expressed in six steps. Complete the steps. 1. If NumItems ................................ then jump to step 6. 2. Increment ................................ 3. If .................................... then set EndOfQueue to ................................ 4. Increment ................................ 5. Set the ................................ at the index stored in ................................ to the ................................ being added. 6. Stop.[6]
This question uses a diagram from the original paper, which isn't shown here. Open the full paper from the past papers archive to see it.
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2023). The mark or mark type is shown in brackets.
- 3 (a) MP1 D3, D4, D1, D2 and D5 in question order or reversed - in any five consecutive locations
- 3 (a) MP2 FoQ value matches index with D3
- 3 (a) MP3 EOQ value matches index with D5
- 6 (b) MP1 If NumItems is / = 8 // (queue) full then jump to step 6
- 6 (b) MP2 Increment EndOfQueue
- 6 (b) MP3 If EndOfQueue = 9 then set EndOfQueue to 1
- 6 (b) MP4 Increment NumItems
- 6 (b) MP5 Set the Element at the index ...
- 6 (b) MP6 stored in EndOfQueue to value/data/item being added
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →