The document presents a C program that implements job sequencing with deadlines using a greedy strategy. It defines a structure for jobs, sorts them by profit, and assigns jobs to time slots based on their deadlines to maximize profit. The output of the program is the sequence of jobs that yields the maximum profit, which is 'cad'.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
4 views2 pages
Lab 8
The document presents a C program that implements job sequencing with deadlines using a greedy strategy. It defines a structure for jobs, sorts them by profit, and assigns jobs to time slots based on their deadlines to maximize profit. The output of the program is the sequence of jobs that yields the maximum profit, which is 'cad'.
int min(int num1, int num2){ return (num1 > num2) ? num2 : num1; } int main(){ Jobs arr[] = { { 'a', 2, 100 }, { 'b', 2, 20 }, { 'c', 1, 40 }, { 'd', 3, 35 }, { 'e', 1, 25 } }; int n = sizeof(arr) / sizeof(arr[0]); printf("Following is maximum profit sequence of Jobs: \n"); qsort(arr, n, sizeof(Jobs), compare); int result[n]; // To store result sequence of Jobs bool slot[n]; // To keep track of free time slots