Skip to content

Commit

Permalink
Merge pull request #176 from praveenmylavarapu/master
Browse files Browse the repository at this point in the history
Fixed 2 typos
  • Loading branch information
Zhenchao Gan authored Oct 30, 2017
2 parents 5e4f537 + 97cc818 commit 740a212
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions C15-Dynamic-Programming/15.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Show how to modify the PRINT-STATIONS procedure to print out the stations in increasing order of station number. (Hint: Use recursion.)

### `Answer`
It's very easy.see my [implementation](./Assembly-line-sche.c)
It's very easy. See my [implementation](./Assembly-line-sche.c)

### Exercises 15.1-2
***
Expand Down Expand Up @@ -36,7 +36,7 @@ Using the result of Exercise 15.1-2, show that the total number of references to
Together, the tables containing fi[j] and li[j] values contain a total of 4n - 2 entries. Show how to reduce the space requirements to a total of 2n + 2 entries, while still computing f* and still being able to print all the stations on a fastest way through the factory.

### `Answer`
It's simple.when we calculate f(n),we just need f(n-1).so we just alloc f1[2] and f2[2].
It's simple. When we calculate f(n),we just need f(n-1).so we just alloc f1[2] and f2[2].


### Exercises 15.1-5
Expand Down
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 740a212

Please sign in to comment.