From 413624f4a29b9de804e3961f4354101f6948db62 Mon Sep 17 00:00:00 2001 From: Ayushi C <67193440+AyushiChakrabarty@users.noreply.github.com> Date: Wed, 4 Nov 2020 10:02:57 +0530 Subject: [PATCH] Create Interval Scheduling_Greedy Approach --- Interval Scheduling_Greedy Approach | 88 +++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 Interval Scheduling_Greedy Approach 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:"<