A stack is created using a high-level language. Memory locations 200 to 207 are to be used to store the stack. The following diagram represents the current state of the stack. TopOfStack points to the last value added to the stack. Stack Pointer Memory location | Value ---|--- 200 | 201 | 202 | 203 | 'F' <- TopOfStack 204 | 'C' 205 | 'D' 206 | 'E' 207 | 'H'
- (a)Complete the following table by writing the answers. | Answer ---|--- The value that has been on the stack for the longest time. | The memory location pointed to by TopOfStack if three POP operations are performed. |[2]
- (b)The following diagram shows the current state of the stack: Stack Pointer Memory location | Value ---|--- 200 | 201 | 202 | 'W' <- TopOfStack 203 | 'Y' 204 | 'X' 205 | 'Z' 206 | 'N' 207 | 'P' The following operations are performed: POP POP PUSH 'A' PUSH 'B' POP PUSH 'C' PUSH 'D' Complete the diagram to show the state of the stack after the operations have been performed. Stack Pointer Memory location | Value ---|--- 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 |[4]
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 2022). The mark or mark type is shown in brackets.
- [2] (a) The value that has been on the stack for the longest time.: 'H'
- [2] (a) The memory location pointed to by TopOfStack if three POP operations are performed.: 206
- [2] (a) One mark per row
- [4] (b) One mark for: TopOfStack pointing to 'D'
- [4] (b) One mark for: Value 'D' in 201
- [4] (b) One mark for: Values 'C' & 'A' in 202 and 203
- [4] (b) One mark for: Values 'X' to 'P' unchanged (204 to 207)
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 →