Past-paper question · 2019 May-June · Paper 42 · Q2(b)(iii)

Question 2(b)(iii) 2019 · May-June · Paper 42 · 7 marks

Original past-paper question for 2(B)(III)
Original past-paper question for 2(B)(III)
Original past-paper question for 2(B)(III)
Reveal official mark-scheme answer Official mark-scheme answer for 2(B)(III)

Official answer for Question 2

Part (b)

(iii)

Question 1

mark for each bullet

Question 7

✓
•
✓
Function Push «
✓
•
✓
«taking parameter (returning Boolean)
✓
•
✓
Checking if Top = 7 «
✓
•
✓
«returning FALSE if full
✓
•
✓
«returning TRUE otherwise
✓
•
✓
if not full, increment Top
✓
•
✓
... add parameter to Top of ArrayStack
✓
FUNCTION Push (BYVALUE DataItem : Integer) (RETURNS Boolean)
✓
IF Top = 7
✓
THEN
✓
RETURN FALSE
✓
ELSE
✓
Top ← Top + 1
✓
ArrayStack[Top] ← DataItem
✓
RETURN TRUE
✓
ENDIF
✓
ENDFUNCTION
✓
9608/42
✓
Cambridge International AS/A Level – Mark Scheme
✓
May/June 2019
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_s19_ms_42.pdf →

Show text version of question

Question 2

Part (b)

(iii)

Question 2

A stack is an Abstract Data Type (ADT).

A
stack contains the values 20, 35, 43, 55.

55 Top of stack

Question 43

Question 35

Question 20

(iii)

The stack is implemented as a 1D array, with eight elements, and given the identifier

ArrayStack.

The global variable Top contains the index of the last element in the stack, or −1 if the stack is empty.

The function Push():

  • takes as a parameter an INTEGER value to place on the stack
  • adds the value to the top of the stack and returns TRUE to show that the operation
  • was successful

  • returns FALSE if the stack is full.

Write an algorithm in pseudocode for the function Push().

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.....................................................................................................................................

[7]

Question 15

Topic relevance

Why this question appears here

82% assigned-topic match · Programming › Structured programming

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9608_s19_qp_42.pdf

Keep practising this topic