Last active
August 29, 2015 14:04
-
-
Save kartikkukreja/04667c9e131bca644b3f to your computer and use it in GitHub Desktop.
Interval Partitioning Problem Implementation
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
sort the n requests in order of start time | |
d = 1 | |
assign request 1 to resource 1 | |
min_pq.insert(1, f(i)) | |
for i = 2 to n: | |
j = min_pq.minIndex() | |
if s(i) >= min_pq.keyOf(j): | |
assign request i to resource j | |
min_pq.increaseKey(j, f(i)) | |
else: | |
d += 1 | |
assign request i to resource d | |
min_pq.insert(d, f(i)) | |
return d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment