Activity Selection Problem is used extensively. Suppose a person is given n activities with their start & finish time. Select
the maximum number of activities that can be performed by a single
person, assuming that a person can only work on a single activity at a
time.
Greedy Approach:
Greedy Approach:
- set n equal to the max finish time
- initialize set of selected activity with a1
- set k=1
- loop m=2 to n
- if start time of current activity is greater than the finish time of last activity
- add the current activity to selected activity
- set k=m
Comments
Post a Comment