An Activity Selection ProblemThe activity selection problem is a mathematical optimization problem. Our first illustration is the problem of scheduling a resource among several challenge activities. We find a greedy algorithm provides a well designed and simple method for selecting a maximum size set of manually compatible activities. Suppose S = {1, 2....n} is the set of n proposed activities. The activities share resources which can be used by only one activity at a time, e.g., Tennis Court, Lecture Hall, etc. Each Activity "i" has start time s_{i} and a finish time f_{i}, where s_{i} ≤f_{i}. If selected activity "i" take place meanwhile the halfopen time interval [s_{i},f_{i}). Activities i and j are compatible if the intervals (s_{i}, f_{i}) and [s_{i}, f_{i}) do not overlap (i.e. i and j are compatible if s_{i} ≥f_{i} or s_{i} ≥f_{i}). The activityselection problem chosen the maximum size set of mutually consistent activities. Algorithm Of Greedy Activity Selector:GREEDY ACTIVITY SELECTOR (s, f) 1. n ← length [s] 2. A ← {1} 3. j ← 1. 4. for i ← 2 to n 5. do if s_{i} ≥ f_{i} 6. then A ← A ∪ {i} 7. j ← i 8. return A Example: Given 10 activities along with their start and end time as S = (A_{1} A_{2} A_{3} A_{4} A_{5} A_{6} A_{7} A_{8} _{A9 A10) Si = (1,2,3,4,7,8,9,9,11,12) fi = (3,5,4,7,10,9,11,13,12,14) } Compute a schedule where the greatest number of activities takes place. Solution: The solution to the above Activity scheduling problem using a greedy strategy is illustrated below: Arranging the activities in increasing order of end time Now, schedule A_{1} Next schedule A_{3} as A_{1} and A_{3} are noninterfering. Next skip A_{2} as it is interfering. Next, schedule A_{4} as A_{1} A_{3} and A_{4} are noninterfering, then next, schedule A_{6} as A_{1} A_{3} A_{4} and A_{6} are noninterfering. Skip A_{5} as it is interfering. Next, schedule A_{7} as A_{1} A_{3} A_{4} A_{6} and A_{7} are noninterfering. Next, schedule A_{9} as A_{1} A_{3} A_{4} A_{6} A_{7} and A_{9} are noninterfering. Skip A_{8} as it is interfering. Next, schedule A_{10} as A_{1} A_{3} A_{4} A_{6} A_{7} A_{9} and A_{10} are noninterfering. Thus the final Activity schedule is:
Next TopicFractional Knapsack problem
