Past-paper question · 2022 October-November · Paper 33 · Q12(a)

Question 12(a) 2022 · October-November · Paper 33 · 6 marks

Original past-paper question for 12(A)
Reveal official mark-scheme answer Official mark-scheme answer for 12(A)

Official answer for Question 12

Part (a)

✓
One mark for each point (Max 6)

Question 6

✓
•
✓
Initialisation of upper bound
✓
•
✓
Test if upper bound is less than lower bound
✓
•
✓
Re-setting of mid value if current value is lower than the target
✓
•
✓
Re-setting of mid value if current value is higher than the target
✓
•
✓
Finding the value
✓
•
✓
Correct termination of loop
✓
Lower 0
✓
Upper 99
✓
Mid 0
✓
Exit FALSE
✓
OUTPUT "Enter the name to be found "
✓
INPUT Target
✓
REPEAT
✓
IF Upper < Lower THEN
✓
OUTPUT Target, " does not exist"
✓
Exit TRUE
✓
ENDIF
✓
Mid Lower + (Upper – Lower + 1) DIV 2
✓
IF Names[Mid] < Target THEN
✓
Lower Mid + 1
✓
ENDIF
✓
IF Names[Mid] > Target THEN
✓
Upper Mid - 1
✓
ENDIF
✓
IF Names[Mid] = Target THEN
✓
OUTPUT Target, " was found at location ", Mid
✓
Exit TRUE
✓
ENDIF
✓
UNTIL Exit // UNTIL Exit = TRUE

Mark scheme 9618_w22_ms_33.pdf →

Show text version of question

Question 12

Part (a)

The array Names[0:99] is in alphabetical order.

Complete this pseudocode binary search algorithm.

Lower ←0 ...................................................................................................... Mid ← 0 Exit ← FALSE OUTPUT "Enter the name to be found " INPUT Target REPEAT

....................................................................................................... THEN

OUTPUT Target, " does not exist" Exit ← TRUE ENDIF Mid ←Lower + (Upper – Lower + 1) DIV 2 IF Names[Mid] < Target THEN

Lower ← ..................................................................................................... ENDIF IF Names[Mid] > Target THEN

..................................................................................................... ENDIF

...................................................................................................... THEN OUTPUT Target, " was found at location ", Mid Exit ← TRUE ENDIF

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

[6]
Topic relevance

Why this question appears here

82% assigned-topic match · Algorithm design and problem-solving › Algorithms

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 9618_w22_qp_33.pdf

Keep practising this topic