May/June 2026 Paper 21

2026 · 9 questions · 28 parts · 75 marks

0/75 marks
0Correct0Partial0Wrong28Unattempted
Filters0 active

Questions

Select a part to jump to its question

Finish set
8(a)Searching AlgorithmsHard4 marks
Global array MyData contains the values shown.
MyData
IndexValue
12
28
39
412
513
615
718
819
920
1023
1125
1226
1339
1438
1540
Study the pseudocode algorithm and array MyData
pseudocode
FUNCTION MyTrace(Target : INTEGER) RETURNS INTEGER   DECLARE LeftPointer, RightPointer, MidPointer : INTEGER   LeftPointer ← 1   RightPointer ← 15   WHILE LeftPointer <= RightPointer      MidPointer ← (LeftPointer + RightPointer) DIV 2      IF MyData[MidPointer] = Target THEN         OUTPUT "Found " & NUM_TO_STR(MidPointer)         RETURN MidPointer      ELSE         IF Target > MyData[MidPointer] THEN            LeftPointer ← MidPointer + 1         ELSE            RightPointer ← MidPointer - 1         ENDIF      ENDIF   ENDWHILE   OUTPUT "Not found"   RETURN -1ENDFUNCTION
Complete the trace table for the function MyTrace when the following pseudocode statement is executed.
pseudocode
Result ← MyTrace(15)
LeftPointerRightPointerMidPointer
8(b)Searching AlgorithmsEasy1 mark
Give the output.

Answer

8(c)Searching AlgorithmsEasy1 mark
Give the value assigned to Result

Answer