ITPEC IP October 2025 Question 8

Source exam: ITPEC IP October 2025Topic: Algorithm and Programming

ITPEC IP October 2025 — Question 8 of 100

Start at index 2 and add the preceding prefix sum — use arr[i - 1] to combine the current input with the sum immediately before it.

The program initializes arr[1] = inputarr[1], so the loop must begin at index 2. For every later index i, the sum through i equals the current value inputarr[i] plus the already calculated sum through i - 1, namely arr[i - 1].

Answer (d)

Why not others:
- (a) and (b) start at 1 and either access beyond the current prefix or use arr[0], outside the 1-based array

- (c) starts correctly but accesses arr[i + 1], which is uncalculated and exceeds the array at i = n

Key rule: A prefix-sum recurrence is prefix[i] = prefix[i - 1] + value[i] after initializing the first element.

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 IP past-paper collection or Report an issue.