CSE 2320 - Assignments - Assignment 6

Submit to Blackboard before the deadline. You will be able to revise your answers until the deadline with no penalty.

IMPORTANT: By submitting your answers, you are certifying that these answers have been exclusively your own work. All students enrolled in this course are expected to adhere to the UT Arlington Honor Code:

I pledge, on my honor, to uphold UT Arlington's tradition of academic integrity, a tradition that values hard work and honest effort in the pursuit of academic excellence. I promise that I will submit only work that I personally create or contribute to group collaborations, and I will appropriately reference any work from other sources. I will follow the highest standards of integrity and uphold the spirit of the Honor Code.


Task 1 (20 pts.)

File knapsack_bottom_up.c contains the implementation of a bottom-up solution for the knapsack problem. Modify the file, to include: Your function knapsack2 should return a solution that contains both the optimal value that can be attained for the specific weight and items, AND a list of the actual objects that produce this value. For example, suppose that the optimal value is 25, and it can be obtained by choosing: Then, the knapsack2 function should return a result such that: Feel free to use files lists.h and lists.c, but you are not allowed to modify those files. The lists used in your code should be defined and accessed using only the interface in lists.h.

Feel free to modify the main function so that it tests your code in any way you see fit.

IMPORTANT: your solution for this task should use bottom-up dynamic programming.


Task 2 (20 pts.)

Do the same thing as in Task 1 (i.e., implement a function called knapsack2, with the exact same signature as in Task 1), but this time using top-down dynamic programming. You can use file knapsack_top_down.c as the basis for your implementation.


Task 3 (20 pts.)

Create a C file called make_change.c, that contains a function make_change with the following signature and specifications:

Signature:

list make_change(int amount, list coins);
Specifications:

Feel free to use files lists.h and lists.c, but you are not allowed to modify those files. The lists used in your code should be defined and accessed using only the interface in lists.h.


Task 4 (10 pts.)

Consider the following definition of a recurrence:

F(0) = 1.
If N is an integer, N > 0, then: F(N) = max{5+F(N-2), 2*F(N-4)}.


Task 5 (15 pts.)

Consider the following definition of a recurrence:

Base case: F(1) = 1.
If N is an odd integer, N > 1, then: F(N) = F(N+1) + 1. If N is an even integer, N > 1, then: F(N) = F(N/2) + 3.


Task 6 (15 pts.)

Consider the following definition of a recurrence:

F(0) = 1.
F(1) = 0.
If N is an integer, N > 1, then: F(N) = max{F(N-2)+F(N-1)+10, 2*F(N-2)}.


How to submit

The assignment should be submitted via Blackboard. Submit a ZIPPED directory called Firstname_Lastname.zip. No other forms of compression are accepted, contact the instructor or TA if you do not know how to produce .zip files. The zipped directory should contain the following documents:

As stated on the course syllabus, programs must be in C or Java, and must run on omega.uta.edu. If you want to do this in any language other than C, you have to re-implement in that language all the code that is currently provided and implemented in C. If you want to use another language or platform, you must obtain prior approval via e-mail by the instructor.

IMPORTANT: Pay close attention to all specifications on this page, including file names and submission format. Even in cases where your answers are correct, points will be taken off liberally for non-compliance with the instructions given on this page (such as wrong file names, wrong compression format for the submitted code, and so on). The reason is that non-compliance with the instructions makes the grading process significantly (and unnecessarily) more time consuming. Contact the instructor or TA if you have any questions.


Back to the list of assignments.