Saint Louis University |
Computer Science 314
|
Dept. of Math & Computer Science |
Topics: Asymptotics, Dynamic Programming
Related Reading: Chapters 3, 4, 9, 15 of CLRS
Due:
10:00am, Monday, September 22, 2014
Please make sure to strictly adhere to the stated course procedures regarding the format of your submitted homework. In particular, your name should not appear on anything other than the cover page, and your solution for each problem must be in a separate packet, labeled appropriately with your assigned codename.
You must also adhere to the policies on academic integrity, paying particular attention to the limits on collaboration.
Exercise 4.3-7 (on page 87 of CLRS). One of the challenges of this is to determine what low-order term to subtract.
Determine a tight asymptotic upper bound for each of the following recurrence equations, and give a formal proof of the upper bound. If the master theorem applies, you simply need to prove what case applies. Otherwise, you might use a recursion tree to guess the answer and the substitution method to prove it by induction. You may assume that T(1) = 1 for all examples.
T(n) = T(n-2) + n2
T(n) = 2T(n-1) + 1
T(n) = T(4n/5) + n
T(n) = 2T(n/4) + sqrt(n)
Exercise 9.3-7 (on page 223 of CLRS). Let me add a few comments:
Note that when they say they want the k numbers that are "closest" to the median, this means in terms of their numeric difference (as opposed to being closest in rank). Also, let's presume that the median itself is not to be included among the k resulting numbers.
As a concrete example, consider S =
If n is even, you may assume that the median is the
smaller of the two middle values. Also, if the
kth closest and
(k+1)st closest elements to the
median are equidistant, you may include either one of them
in your result. For example if
Exercise 15.3-5 (on page 390 of CLRS).
During hard times, a company with n employees is planning to cut costs through massive layoffs. The company is organized using a classic hierarchy that can be modeled as a general tree, with everyone (other than the president) reporting directly to one other person. The Board of Trustees is considering whom to layoff (including, perhaps, the president), however to make sure that responsibilities for current work don't get reassigned too far, they have decided that they will never fire an employee and his or her direct manager.
Given this constraint, their goal is to shed as much salary as possible through the layoffs. For notation, let sp denote the current salary for person p. There are 2n possible subsets of employees to consider laying off (not that all of those subsets will meet the constraint about an employee and manager), but a brute force search through all of those subsets is quite expensive. Fortunately, dynamic programming can be used to find the optimal subset of employees to fire in considerably less time.
You are to describe such an efficient solution using dynamic programming. In evaluating your writeup, we will be looking for how you address the following issues:
Exercise 15-3 (on page 405 of CLRS).