ITPEC FE Subject B April 2026 Question 14

From the answer group below, select the correct combination of answers to be inserted into A and B in the program. Here, the array indexes start at 1.

Percentile is a statistical measure used to describe the position of a particular value in a dataset relative to the remainder of the values. In education, percentiles are commonly used to rank students’ performance. For instance, if a student is in the 90th percentile, it implies the score of the student is higher than 90% of the other students. To calculate percentile of a student, use the following formula:

percentile = number of students who scored below the target student’s scoretotal number of students − 1 × 100

For instance, if the scores of five students are given as an array {30, 60, 80, 72, 15}, then the percentile array for each student will be {25, 50, 100, 75, 0}. This implies that the number of students with scores less than 30 is 1; thus, the percentile for the first student is (1 ÷ (5 - 1) × 100) = 25, the number of students with scores less than 60 is 2, and the percentile for the second student is (2 ÷ (5 - 1) × 100) = 50. The same applies thereafter.

The function calculatePercentile receives the scores of each student in the argument arr and calculates and returns the percentile of each student. Assume that the argument arr contains two or more numbers between 0 and 100.

[Program]
○ real []: calculatePercentile(integer []: arr)
integer: n ← the number of elements of arr
real []: percentiles ← {n zeros}
integer: i, j, count
for (increase i from 1 to n by 1)
count ← 0
for (increase j from 1 to A by 1)
if (arr[i] > arr[j])
count ← count + 1
endif
endfor
percentiles[i] ← B
endfor
return percentiles

Answer group

OptionAB

Explanation

A: n, B: (count ÷ (n - 1)) × 100 — count the students below each score across the whole class, then apply the formula as given.

Blank A. "Number of students who scored below" means comparing arr[i] with every student, so j runs from 1 to n. When j = i the test arr[i] > arr[j] is false, so nobody is counted against themselves.

Blank B. The formula divides that count by the number of students minus one and multiplies by 100. count already is the number below; nothing is subtracted from it.

Check on {30, 60, 80, 72, 15}: for 30 only 15 is lower, so count = 1 and 1 ÷ 4 × 100 = 25. For 80 all four others are lower: 4 ÷ 4 × 100 = 100. Both match the stated result.

Answer (f)

Why not others:

  • •(a) and (b) (A = i) — compare each student only with those stored before them; the first student always gets 0, so 30 would come out as 0, not 25
  • •(c) and (d) (A = i - 1) — the same flaw with one comparison fewer; for the first student the loop does not run at all
  • •(e) (B uses count - 1) — subtracts one from a count that is already correct: 30 would get 0 ÷ 4 × 100 = 0, and the lowest score, 15, would get -25

Key rule: A rank or percentile compares each element with the whole data set, so the inner loop must span all n elements; a bound tied to i makes the result depend on storage order.

Math & Data Science · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.