diff --git a/Interval Scheduling_Greedy Approach b/Interval Scheduling_Greedy Approach new file mode 100644 index 0000000..62e94a9 --- /dev/null +++ b/Interval Scheduling_Greedy Approach @@ -0,0 +1,88 @@ +//Interval Scheduling question + +#include +#include +#include +using namespace std; + +// declare a structure with start and finish time variables +struct act +{ + int start; + int finish; +}; + +//Element ascending order comparison on the basis of finish time +bool comp(act a1, act a2) +{ + return (a1.finish < a2.finish); +} + +//Find the maximum subset of mutually compatible jobs +void max_act(act a[], int n) +{ + int j,i=0; + int count; + sort(a, a+n,comp); //sorting on the basis of finish time + + cout << "Maximum subset of mutually compatible jobs are:"<