Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kartikkukreja/04667c9e131bca644b3f to your computer and use it in GitHub Desktop.
Save kartikkukreja/04667c9e131bca644b3f to your computer and use it in GitHub Desktop.
Interval Partitioning Problem Implementation
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