0

We know that there is a Greedy algorithm for scheduling of $n$ jobs which each job has its own deadline and profit.

In greedy algorithm, we sort the set by their profit descendant, And if a job can add to a possible set of jobs, we add it to the set.

A job can be added to the set, if it starts before its deadline and each work need 1 time slot for doing.

Is there any $O(nlogn)$ algorithm for this problem as follows?

  • Sorting the set by their profit using merge sort in $O(nlogn)$
  • Add the first job to the possibility set.
  • For remain jobs, add the job to the set of its deadline is less than its index in possibility set.
  • We have to remain the possible set sorted. Then for each new coming job, we can add it to the set using binary search in $O(logn)$

Total cost of the above algorithm is $O(nlogn)+O(n)*O(logn)=O(nlogn)$

Is this algorithm correct?

Mohammad
  • 1
  • 2

0 Answers0