Past-paper question · 2015 October-November · Paper 32 · Q6(c)(v)

Question 6(c)(v) 2015 · October-November · Paper 32 · 22 marks

Question 6

Part (c)

(v)

Question 6

. . . .

2000

[4]

Question 12

Part (c)

An algorithm is designed in pseudocode to search the binary tree for a particular food name.

The algorithm uses the additional variables below:

Variable Data type Description SearchFood STRING Food name to search for Current INTEGER The array subscript for the item currently considered IsFound BOOLEAN Flags to TRUE when SearchFood is found

Complete the algorithm below:

//binary tree search

INPUT SearchFood

IsFound ← ............................................................................................................................

Current ← ............................................................................................................................

REPEAT

IF Food[Current] = ......................................................................................................

THEN

//found

OUTPUT "Found"

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

ELSE

IF SearchFood < Food[Current]

THEN

// move left

Current ← LeftPtr[Current]

ELSE

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

ENDIF

ENDIF

UNTIL IsFound = TRUE OR ...............................................................................................

IF IsFound = FALSE

THEN

OUTPUT SearchFood "Not Found"

ENDIF

[6]

Question 13

Part (d)

(i)

The dataset used in part

Part (b)

was:

MELON, BEETROOT, TURNIP, APPLE, PARSNIP, SWEDE, QUINCE

Draw the binary tree.

[2]
A
well-balanced tree has approximately the same number of nodes in the left and right

subtrees.

(ii)

State whether or not this is a well-balanced tree.

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

.......................................................................................................................................[1]

Question 14

5 A busy main road connects Town A and Town B. A large new housing development is being built near the main road. A new road from the housing development will connect to the main road. Traffic control signals are planned for the junction.

It is proposed to simulate the traffic flows to assist the planning of the traffic control system.

7RZQ$

+RXVLQJ

  • XQFWLRQ

GHYHORSPHQW

7RZQ% The number of traffic lanes approaching the junction could be an input variable for the simulation.

(v)

CountBig("ScoreC", 19, 'N')

.......................................................................................................................................[1]

Question 17

Part (b)

The function header used in part

Part (a)

was:

FUNCTION CountBig(ThisArray : ARRAY OF INTEGER,

ThisValue : INTEGER,

ThisFlag : CHAR) : INTEGER

(i)

Use the following letters to label your function header above.

A
Function parameter(s)
B
Where the return data type is stated
[2]

(ii)

Write a single statement which calls the function CountBig to count the number of times

value 83 or larger is found in the array Rejects.

The function returns the value to the variable RejectCount in the calling statement.

.......................................................................................................................................[2]

Part (c)

A programmer writes pseudocode for a new function StringFound. The function is to report

whether or not a string value ThisValue is found in the string array ThisArray. The function returns a Boolean value.

Write the function header for function StringFound.

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

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

...............................................................................................................................................[4]

Question 18

Reveal official mark-scheme answer

The answer for this question is in the official mark scheme: open the mark scheme.

Mark scheme 9691_w15_ms_32.pdf →

Topic relevance

Why this question appears here

99% assigned-topic match · Data types and structures › Data types and records

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 9691_w15_qp_32.pdf

Keep practising this topic