Past exam of the mathematics course of the University of Cambridge 2023 ii Paper 4 30J b Solution Created 2026-09-24 Updated 2026-09-25
With , it suffices to put the threshold between and for . Form the prefix sumsThey take operations to compute. The minimized squared errors for the two children areandEach candidate value therefore takes constant time once the prefix sums are available. Scanning all candidates takes operations in the sense of Big O notation, and retaining the minimizing gives the optimal split.