ITPEC FE Subject B April 2026 Question 3
ITPEC FE Subject B April 2026 — Question 3 of 20
The blank must hold p ← p + abs(S[i] - T[i]), accumulating the absolute difference of each coordinate pair.
The Manhattan distance is the sum of |Sᵢ − Tᵢ| over all i, so each iteration must take the difference first, make it non-negative with abs, and add it to the running total held in p.
Answer (b)
Why not others:
- (a) — adds the coordinates instead of subtracting them; abs(S[i] + T[i]) measures nothing about how far apart the vectors are
- (d) — subtracts each term from p, so the result is the negative of the distance; a distance can never be negative
- (c) — combines both errors, adding the coordinates and then subtracting the result
Key rule: Read the formula symbol by symbol. The summation sign means accumulate with +, the bars mean abs, and the minus inside them must stay a minus.
AI-generated — may contain errors
The original exam layout is preserved in the image so diagrams, formulas, tables, and code remain accurate.
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.