Content deleted Content added
m →Weighted: Reworded paragraph |
→Weighted: Clarified code and fixed a typo |
||
Line 46:
int w[numOfVectors + 1]; // w[j] is the weight for v[j].
int p[numOfVectors + 1]; // p[j] is the # of vectors that end before v[j] begins.
int M[numOfVectors + 1];
int finalSchedule[];
// v[0] does not exist
w[0] = 0; p[0] = 0; M[0] = 0;
// The following code determines the value of M for each vector.
// The maximum weight of the schedule is equal to M[numOfVectors].
for (int i = 1; i <
M[i] = max(w[i] + M[p[i]], M[i - 1]);
}
//
schedule (j) {
if (j == 0) { return; }
|