Question 6(c)(ii) 2015 · October-November · Paper 32 · 16 marks
Question 6
Part (c)
(ii)
Question 6
. . . .
2000
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
Question 13
Part (d)
(i)
The dataset used in part
Part (b)
was:
MELON, BEETROOT, TURNIP, APPLE, PARSNIP, SWEDE, QUINCE
Draw the binary tree.
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.
(ii)
State an output variable which will provide data for the planning process for the traffic
control system.
...........................................................................................................................................
.......................................................................................................................................[1]
Question 16
Question 6
Part (a)
A user-defined function CountBig is defined, using pseudocode, as follows:
CountBig(ThisArray : ARRAY OF INTEGER, ThisValue : INTEGER, ThisFlag : CHAR) : INTEGER
The function checks each element in the array ThisArray. It counts the number of elements which are greater than (or greater than or equal to) ThisValue.
The function returns the count value.
ThisFlag has two permitted values:
- Y – indicates values equal to ThisValue are to be included in the count
- N – indicates values equal to ThisValue will not be included in the count
An error is generated if the function is not correctly formed.
The function is used with the three arrays shown below:
Subscript/Index Identifier 1 2 3 4 5 6 7 8 9 10
ScoreA 16 19 23 28 28 36
ScoreB 71 67 51 82 77 12 80 16
ScoreC 19 19 19 19 19 19 19 19 19
State the value returned by the following function calls:
(i)
CountBig(ScoreA, 23, 'Y')
.......................................................................................................................................[1]
(ii)
CountBig(ScoreB, 71, 'N')
.......................................................................................................................................[1]
Reveal official mark-scheme answer
The answer for this question is in the official mark scheme: open the mark scheme.
Why this question appears here
98% assigned-topic match · Data types and structures › Arrays
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
