Skip to content

Instantly share code, notes, and snippets.

@kartikkukreja
Last active August 29, 2015 14:04
Show Gist options
  • Save kartikkukreja/ee8671b8ab5c647f5252 to your computer and use it in GitHub Desktop.
Save kartikkukreja/ee8671b8ab5c647f5252 to your computer and use it in GitHub Desktop.
Segmented Least Squares Problem
OPT[0] = 0
for j = 1 to n:
for i = 1 to j:
compute e(i, j) for the segment pi, pi+1, ..., pj
for j = 1 to n:
OPT(j) = min((e(i,j) + C + OPT[i-1]) forall 1 ≤ i ≤ j)
return OPT[n]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment