DEV Community

Rishi Raj
Rishi Raj

Posted on

Scheduling Algorithm

This Python Notebook (https://github.com/rishiraj824/scheduling/blob/master/scheduling.ipynb) demonstrates the scheduling algorithm for a list of activities provided through a CSV. It uses the dynamic programming approach to solve for the most compatible activities.

The above solution works for any given activity board as it takes into account the maximum earnings from those activities.

Step 1.
We first sort all our activities based on their finish times and compare the activities one by one to find the next compatible activity because activities cannot overlap each other.

Step 2.
We use a binary search to find the most compatible activity. This takes us O(lg n) time.

Step 3.
We do this n times and while we do this we save the activity names to output all the possible activities in the end.

Step 4.
Keep adding the reward of all the compatible, highest rewards and display the sum in the end.

Discussion (1)