User interface language: English | Español

Date November 2018 Marks available 1 Reference code 18N.1.SL.TZ0.10
Level SL Paper 1 Time zone no time zone
Command term Identify Question number 10 Adapted from N/A

Question

The following method, calcBMI() accepts person’s height (H) in metres (m) and weight (W) in kilograms (kg) and returns their Body Mass Index (BMI).

calcBMI(H, W)
X = H * H
B = W / X
return B
endcalcBMI

Boris weighs 104 kg and is 2.00 m tall. His BMI can be calculated by calling method calcBMI() as follows

BorisBMI = calcBMI(2.00, 104).

A person can belong to one of the following four weight categories:

The data about a group of adults and their height measurement (in metres) and weight measurement (in kg) is held in three one-dimensional arrays.

Where
NAME is a one-dimensional array holding names (currently sorted in alphabetical order).
WEIGHT is a one-dimensional array holding weight measurement in kilograms.
HEIGHT is a one-dimensional array holding height measurement in metres.

For example,
NAME[0] is Annie.
Her weight measurement is 52.40 kg and can be found in WEIGHT[0].
HEIGHT[0] is 1.56 which represents Annie’s height measurement in metres.

State the value of variable BorisBMI.

[1]
a.

Use pseudocode to construct an algorithm which accepts a person’s BMI and outputs the weight category the person belongs to.

[4]
b.

State the name of the person whose height is held in HEIGHT[3].

[1]
c.

Identify one reason why a binary search algorithm cannot be used to find the name of person whose height is given.

[1]
d.i.

Describe how the name of person whose height is given could be output.

[2]
d.ii.

Construct an algorithm which will output the names of all the people whose BMI is greater than this group’s average BMI.

You should call method calcBMI() in your answer.

[6]
e.

Markscheme

Award [1 max].

26.0;

a.

Award [4 max].

Award [1] for outputting 'underweight' and correct condition in if statement.
Award [1] for outputting 'normal weight' and correct logical expression (18.5 < B < 25.0).
Award [1] for outputting 'overweight ' and correct logical expression (25.0 < B < 30.0).
Award [1] for outputting 'obese' (30.0 and greater than 30.0).
Award [1] for using if-else.

Example answer 1:

category(B)
if B < 18.5
output('underweight')
else if B < 25.0
output('normal weight')
else if B < 30.0
output('overweight')
else
output('obese')
end if
end category

Example answer 2:

category(B)
if B < 18.5
output('underweight')
end if
if B >= 18.5 and B < 25.0
output('normal weight')
end if
if B >= 25.0 and B < 30.0
output('overweight')
end if
if B >= 30.0
output('obese')
end if
end category
b.

Award [1 max].

Paul;

c.

Award [1 max].

Binary search can be applied only on sorted array / array HEIGHT is not sorted so binary search cannot be used;

d.i.

Award [1] for identifying each stage in the process of printing out a person’s name up to [2 max].

Linear (sequential) search could be used to find the position (array index) of a given height measurement in array HEIGHT;
And the name in array NAME at found position should be outputted;

d.ii.

Award [6 max].

Award [3 max] marks for calculating average.
Award [1] for initialization and changing the sum (of all BMIs) within the loop.
Award [1] for a correct loop.
Award [1] for correct parameters in the call of method calcBMI().
Award [1] for calculating average for the 30 persons (sum of all BMIs over 30).

Award [3 max] marks for displaying appropriate names after calculating the group’s average BMI.
Award [1] for an if statement within the correct loop.
Award [1] for condition in if (comparing the BMI of the person with the average BMI).
Award [1] for the correct output [1] for correct parameters in the method call
(calcBMI(HEIGHT[K], WEIGHT[K]).

Example answer:

sum = 0
loop for K from 0 to 29
sum = sum + calcBMI(HEIGHT[K], WEIGHT[K])
end loop
average = sum/30

loop for K from 0 to 29
if calcBMI(HEIGHT[K], WEIGHT[K]) > average then
output(NAME[K])
end if
end loop
e.

Examiners report

[N/A]
a.
[N/A]
b.
[N/A]
c.
[N/A]
d.i.
[N/A]
d.ii.
[N/A]
e.

Syllabus sections

Topic 4: Computational thinking, problem-solving and programming » 4.2 Connecting computational thinking and program design
Show 59 related questions
Topic 4: Computational thinking, problem-solving and programming

View options