A program stores data in a text file. When data is read from the file, it is placed in a queue. (a) The diagram below represents an Abstract Data Type (ADT) implementation of the queue. Each data item is stored in a separate location in the data structure. During initial design, the queue is limited to holding a maximum of 10 data items. The operation of this queue may be summarised as follows: • The Front of Queue Pointer points to the next data item to be removed. • The End of Queue Pointer points to the last data item added. • The queue is circular so that locations can be reused. [Figure 3.1] (ii) The following diagram shows the state of the queue after several operations have been performed. All queue locations have been used at least once. [Figure 3.2]
- (a)(i)Describe how the data items Orange and Yellow are added to the queue shown in the diagram.[4]
- (a)(ii)State the number of data items in the queue.[1]
- (b)The design of the queue is completed and the number of locations is increased. A function AddToQueue() has been written. It takes a string as a parameter and adds this to the queue. The function will return TRUE if the string was added successfully. A procedure FileToQueue() will add each line from the file to the queue. This procedure will end when all lines have been added or when the queue is full. Describe the algorithm for procedure FileToQueue(). Do not use pseudocode in your answer.[5]
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 (May/June 2023). The mark or mark type is shown in brackets.
- [4] One mark per point: 1 Check that the queue is not full 2 EoQ pointer will move to point to location 9 3 Data item Orange will be stored in location referenced by EoQ pointer 4 EoQ pointer will move to point to location 0 5 Data item Yellow will be stored in location referenced by EoQ pointer Note: max 4 marks
- [1] 7
- [5] One mark per bullet: 1 Open file in READ mode 2 Loop to EOF() // read / process all the lines in file 3 Loop will end when return value from AddToQueue() is FALSE / queue is full 4 Read a line from the file in a loop 5 Pass string to AddToQueue() // AddToQueue () is executed with line as parameter
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 →