Setting
- We are given set of requests
- has a start time by and a finish time given by
- Additionally, each has a weight/value given by
- There is a machine which can handle one request at a time
- Two requests “conflict” if they overlap
The
Select a set of requests such that is maximised and no two requests from conflict.
Correct algorithm via dynamic programming
Order the requests in increasing order of finish times.
For each request , we define to be last compatible request with

There are requests ordered in increasing order of finish times. We will maintain an array of length : for each
- stores the value of the set of requests of maximum weight which can be chosen for the sub-instance containing requests
Goal: Compute from the entries
- which we have computed previously
- Bottom-up approach
Easy, but crucial, observation while computing Either the request is chosen in or not
- If request is chosen, then we should set
- Follows fm definition of and the array
- If request. is not chosen, then we should set
- Follows from definition of the array .
Recurrence:
Algorithm : Weighted Interval Scheduling with requests
Correctness
- Proof by induction on
- Base case is
- Inductive step essentially argues the correctness of the recurrence
Running time
- Sort the requests in increasing order of finish times in time
- This allows us to find for each
- Filling up the entry for needs to look at two existing entries from the array , and do one addition & one max operation
- This needs constant time
- Hence, time required to fill up all entries is
Note
The running time of DP algorithms is measured in terms of size of the array/table and amount of operations needed to compute this array/table.