UMBC CMSC441, Design & Analysis of Algorithms, Fall 2014


Homework 6

Due Thursday, October 9, 2014


  1. Sorting 0 to n3 − 1. Exercise 8.3-4, page 200.
    Additional instructions: Do justify the running time of your algorithm.

    Reminder: Please do not use pseudocode (or actual code) to present your algorithm. Give a high-level description using complete English sentences in paragraph form. Resort to pseudocode only if implementation details are needed to justify the correctness or the running time of your algorithm. Finally, pseudocode, if included, must be commented, just like regular code.


  2. Planning a company party. Problem 15-6, page 408.

    Additional Instructions: When you are asked to provide a dynamic programming algorithm. You must provide the following:

    1. Define a function OPT that can be used to solve this dynamic programming problem. To do this, you must describe the input parameters to OPT and the "return value" using English sentences. (Note: you are specifying the input-output relation of the function. You should not describe how to compute the function.)
    2. Give a mathematical formula that shows how OPT can be computed recursively. Then, explain all the major parts of the formula using English sentences. Remember to include the base cases.
    3. Describe how OPT can be computed bottom up using a dynamic programming table. Be sure to include a description of the dimensions of the table and the order that the entries of the table are to be filled. Draw a diagram. Which entry has the solution to the original problem? (For this question your "table" is tree-shaped.)
    4. Analyze and justify the running time of your dynamic programming algorithm.


  3. The Deadly TSU Cafeteria.

    At Tummiache State University, the cafeteria at the student center has a very limited selection of food — none of which is very healthy. The pre-med majors did some research and produced a table showing the number of days that a student's life expectancy would be reduced based upon the selection of food and the number of servings eaten during the student's lifetime.

    Example: The following table is an example where the student must eat n = 10 lunches and the cafeteria offers k = 4 food items.

      Number of Servings
    Food Items 0 1 2 3 4 5 6 7 8 9 10
    Bad Bland Burritos 0 2 4 6 8 10 12 14 16 18 20
    Greasy Gooey Pizzas 0 3 6 12 18 24 30 36 48 50 62
    Hockey Puck Burgers 0 5 10 30 50 60 70 80 90 100 100
    Chewy Chicken Filets 0 15 15 15 15 15 16 16 16 16 16

    For example, if a student eats 2 servings of Bad Bland Burritos, 5 of Greasy Gooey Pizzas, 1 of Hockey Puck Burgers and 2 of Chewy Chicken Filets, then his life expectancy will be reduced by 4 + 24 + 5 + 15 = 48 days.

    Notes:

    Describe a dynamic programming algorithm that minimizes the total reduction in the student's life expectancy after eating n lunches from the k choices. Report your running time in terms of both n and k.

    Additional Instructions: When you are asked to provide a dynamic programming algorithm. You must provide the following:

    1. Define a function OPT that can be used to solve this dynamic programming problem. To do this, you must describe the input parameters to OPT and the "return value" using English sentences. (Note: you are specifying the input-output relation of the function. You should not describe how to compute the function.)
    2. Give a mathematical formula that shows how OPT can be computed recursively. Then, explain all the major parts of the formula using English sentences. Remember to include the base cases.
    3. Describe how OPT can be computed bottom up using a dynamic programming table. Be sure to include a description of the dimensions of the table and the order that the entries of the table are to be filled. Draw a diagram. Which entry has the solution to the original problem?
    4. Analyze and justify the running time of your dynamic programming algorithm.


Last Modified: 1 Oct 2014 17:55:28 EDT by Richard Chang
to Fall 2014 CMSC 441 Section 2 Homepage