A stack is to be set up using the information in the table. [Table with Identifier: BasePointer, TopPointer, Stack; Data type: INTEGER, INTEGER, REAL; Description: points to the bottom of the stack, points to the top of the stack, 1D array to implement the stack] A constant, with identifier Capacity, limits the size of the stack to 25 items.
- (a)Write the pseudocode for the required declarations.[3]
- (b)Complete the pseudocode function Pop () to pop an item from Stack. // popping an item from the stack FUNCTION Pop() DECLARE Item : REAL Item ← 0 BasePointer THEN Item ← TopPointer ← ELSE OUTPUT "The stack is empty – error" ENDIF ENDFUNCTION[5]
- (c)Compare and contrast the queue and stack Abstract Data Types (ADT).[2]
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2023). The mark or mark type is shown in brackets.
- [1] One mark per mark point (Max 3) MP1 Correct constant declaration
- [1] MP2 Two correct variable declarations
- [1] MP3 Correct array declaration
- [1] Example answer: CONSTANT Capacity = 25 DECLARE BasePointer : INTEGER DECLARE TopPointer : INTEGER DECLARE Stack : ARRAY[1:25] OF REAL
- [1] One mark for each correctly completed line (Max 5)
- [1] One mark per mark point (Max 2) MP1 A queue is a first in first out / FIFO data structure and a stack is a first in last out / FILO / LIFO data structure // Data is removed from a queue in the order it is received and removed from a stack in the reverse order to which it is received
- [1] MP2 Both ADTs can vary in size / are of indeterminate length
- [1] MP3 Data is popped and pushed (onto/from a stack) at the same end but it is enqueued and dequeued (to/from a queue) at different/opposite ends // a queue has two accessible ends and a stack has only one
- [1] MP4 A stack has only one moveable pointer whereas a queue has two.
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 →