Created
February 8, 2014 10:28
-
-
Save arkanath/8881598 to your computer and use it in GitHub Desktop.
Interval Scheduling Problem - Pseudocode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Problem: Given set of intervals with starting time and end time, give the set of intervals with maximum cardinality such that no intervals overlap. | |
Algorithm: | |
* Initially let R be the set of all requests. | |
* While R is not empty: | |
* Choose a request i with earliest finish time | |
* add to queue A | |
* delete all incompatible from R. | |
* EndWhile | |
* Return A | |
Analysis: | |
* A is compatible | |
* A is optimal with the "Stays Ahead" argument. | |
* Running Time : O(n logn) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment