Interval scheduling: Difference between revisions

Content deleted Content added
Weighted: added citation
Weighted: fixed code
Line 47:
int p[numOfVectors+1]; //p[j] is the # of vectors that end before v[j] begins.
int M[numOfVectors+1];
int finalSchedule[numOfVectors];
 
//v[0] does not exist. The first interval vector is set to v[1].
Line 56:
}
 
//The maximum weight of the schedule is equal to M[numOfVectors+1].
 
int index = numOfVectors-1;
 
schedule(j){
if(j==0){return;}
else if(w[j]+M[p[j]] >= M[j-1]){
prepend(v[j], finalSchedule); //addprepends v[j] to schedule.
finalSchedule[index] = v[j];
index--;
schedule(p[j]);
} else {schedule(j-1);}