Skip to content

Commit

Permalink
Fixed 2 typos
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenmylavarapu committed Oct 28, 2017
1 parent 5e4f537 commit bca5ca4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions C16-Greedy-Algorithms/16.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Suppose that we have a set of activities to schedule among a large number of lec
### `Answer`
Find the smallest number of lectures halls to schedule a set of activities S in.To do this efficiently move throught the activities according to starting and finishing times. Maintain two lists of lecture halls: Halls that are busy at time t and halls that are free at time t. When t is the starting time for some activity schedule this activity to a free lecture hall and move the hall to the busy list. Similarly, move the hall to the free list when the activity stops. Initially start with zero halls. If there are no halls in the free list create a new hall.

The above algorithm uses the fewest number of halls possible : Assume the algorithm used m halls. Consider some activity a that was the first scheduled activity in lecture hall m. i was put in the mth hall because all of the m-1 halls were busy, that is, at the time a is scheduled there are m activities occuring simultaneously. Any algorithm must therefore use at least m halls, and the algorithm is thus optimal.
The above algorithm uses the fewest number of halls possible : Assume the algorithm used m halls. Consider some activity a that was the first scheduled activity in lecture hall m. i was put in the mth hall because all of the m-1 halls were busy, that is, at the time a is scheduled there are m activities occurring simultaneously. Any algorithm must therefore use at least m halls, and the algorithm is thus optimal.

The algorithm can be implemented by sorting the activities. At each start or finish time we can schedule the activities and move the halls between the lists in constant time. The total time is thus dominated by sorting and is therefore O(nlgn).

Expand All @@ -62,7 +62,7 @@ Selecting the activity with the least duration from example a will result in sel

The activity with the minimum overlap in example b is the middle activity in the top row. However, selecting this activity eliminates the possibility of selecting the optimal solution depicted in the second row.

Seleting the activity with the earliest starting time in example c will yield only the one activity in the top row.
Selecting the activity with the earliest starting time in example c will yield only the one activity in the top row.

***
Follow [@louis1992](https://github.com/gzc) on github to help finish this task.
Expand Down

0 comments on commit bca5ca4

Please sign in to comment.