JobID Deadline Profit
1 2 20
2 2 15
3 1 10
4 3 5
5 3 1
Job sequenced in order: 2 1 4
Here the maximum deadline is 3. Maximum profit is given by Job1. And since it has deadline 2 it occupies position2 in the job sequence. Next maximum profit is given by Job2. Since position 2 is occupied by Job1, it occupies the next position to the front of 2 ie. position1. We do not take Job3 into consideration because, it has deadline 1 and position 1 is already filled with a better job. Next, Job4 is taken and placed in position3, since it has maximum profit compared to Job5.
Name | Views | Likes |
---|---|---|
C++ : Find HCD and LCM in one line code | 2441 | 0 |
C++ Counting occurrences using MAP (STL) | 7033 | 0 |
C++ Splitting a sentence into words and putting into a container | 1675 | 0 |
C++ Job Sequencing with deadline (Greedy approach) | 4396 | 0 |
C++ std::wcin | 950 | 0 |
C++ std::wcout | 1292 | 1 |
C++ memset() | 313 | 0 |
C++ CHECK NUMBER IS ODD OR EVEN USING NOR | 212 | 0 |
Make C++ run faster | 355 | 1 |
Comments