Engineering

Computer ScienceQ&A LibraryKnapsack Problem This exercise is due Tuesday, May 14. It has to be turned in on time in order to get participation credit. I'll come into class and go over the solution right away. Then I will collect your work on the exercise. Be ready to turn it in at that time . Fill out the table for the knapsack problem, where the objects weights, and values are as given and the overall weight limit is 10 Next, circle the entries in the table that are used when backtracking to find objects to use in the solution. Then list the object numbers that can be used for an optimal solution. Also list the weights and values of those objects Verify that the values of your solution objects add up to the optimal number in the last row and column in the table Verify that the sum of the weights of your solution the objects is not more than the overall weight limit of 10 Weight Capacity - wt val 1 2 3 4 5 6 789 10 Here is a filled-out table for a similar problem: Total Weight -- #wtval 1 0 1 2 3 4 5 6 0 2 2 2 2 2 2 2 0 2 3 7 9 11 12 16 Let me know in class if you have questions about how such problems are solved. The algorithm is covered in section 6.4Question

**Knapsack Problem**

This exercise is due Tuesday, May 14. It has to be turned in on time in order to get participation credit. I'll come into class and go over the solution right away. Then I will collect your work on the exercise. Be ready to turn it in at that time.

- Fill out the table for the knapsack problem, where the objects, weights, and values are as given, and the overall weight limit is 10.
- Next, circle the entries in the table that are used when backtracking to find objects to use in the solution.
- Then list the object numbers that can be used for an optimal solution.
- Also list the weights and values of those objects.
- Verify that the values of your solution objects add up to the optimal number in the last row and column in the table.
- Verify that the sum of the weights of your solution the objects is not more than the overall weight limit of 10.

Weight Capacity ----->

obj

# wt val | 0 1 2 3 4 5 6 7 8 9 10

_________________________________________________________

0 0 0 | 0 0 0 0 0 0 0 0 0 0 0

1 4 5 | 0

2 3 4 | 0

3 5 7 | 0

4 3 2 | 0

**Here is a filled-out table for a similar problem:**

Total Weight ----->

obj

# wt val | 0 1 2 3 4 5 6 7

_____________________________________________

0 0 0 | 0 0 0 0 0 0 0 0

1 1 2 | 0 2 2 2 2 2 2 2

2 4 9 | 0 2 2 2 9 11 11 11

3 3 7 | 0 2 2 7 9 11 11 16

4 2 3 | 0 2 3 7 9 11 12 16

Let me know in class if you have questions about how such problems are solved. The algorithm is covered in section 6.4.

1 Rating

Tagged in

Find answers to questions asked by student like you

Show more Q&A

Q: How do you convert 172.16.20.55 to binary format?

A: 172.16.20.55 represents IP address in decimal format. In order to convert it into binary format we n...

Q: How do I check if a binary number is a multiple of 16 by using bit shifting?

A: Approach: Result = (((n >>4) << 4) == n). First we shift the 4 bit right then we shift t...

Q: 2. Write a program called ListOddNumbers that prints the below (there is a single space between each...

A: Solution: 2. The below program is written in Java language to display the odd number between 1 and 5...

Q: Write a program called Convert, which converts an ASCII code to its equivalentcharacter. 1) Create a...

A: Java codeimport java.util.Scanner; public class Convert{public static void main(String[] args) {Scan...

Q: Programming in C language.

A: Note:The below program has been complied and run in "repl.it" online complier.

Q: what is the best test strategy for any ERP system?

A: ERP stands for Enterprise resource planning is a software used for business process management. It a...

Q: Associate each of the following concepts with one of the languages we covered (pseudo code,FORTRAN, ...

A: Associating languages with given concepts:ALGOL 60: Pass by nameALGOL 60: Pass by valueFORTRAN: Assi...

Q: import java.util.*;public class TestAverage {public static void main(String[] args) {int test1, test...

A: Click to see the answer

Q: A Maze Room : In this lab, we will make a maze game. The maze is based on Linked Lists. Instead of h...

A: For class Room, implement the setter and getter methods by assign and returning values respectively....