Question

In: Computer Science

Fractional Knapsack Problem Algorithm which best describes the tightest range of the number of items with...

Fractional Knapsack Problem Algorithm
which best describes the tightest range of the number of items with only fractional inclusion (i.e. not entirely included or excluded) in the knapsack? (Let n denote the number of items for possible inclusion.)
A) At least 0 items and at most n items
B) At least 1 items and at most n items
C) Exactly n items
D) At least 0 items and at most n-1 items
E) At least 1 items and at most n-1 items
F) At least 0 items and at most 1 items
G) Exactly 1 items
H) Exactly 0 items

Fractional Knapsack Problem - Time Complexity
Assuming that the values per weight can be represented with no more than three digits each before and after the decimal point, which best describes the TOTAL time complexity of our greedy algorithm for the Fractional Knapsack Problem?
A) Θ(log n)
B) Θ(n)
C) Θ(n log log n)
D) Θ(n log n)
E) Θ( n^2)
F) Θ(n^2 log n)

Fractional Knapsack Algorithm- Fractional Case
In the greedy algorithm for the Fractional Knapsack Problem, what should go in the blank to determine the fraction being used?
A) fraction = initialCapacity / value[i]
B) fraction = initialCapacity / weight[i]
C) fraction = initialCapacity / (value[i]/weight[i])
D) fraction = remainingCapacity / value[i]
E) fraction = remainingCapacity / weight[i
F) fraction = remainingCapacity / (value[i]/weight[i])

Solutions

Expert Solution

1) B) At least one item and at most n items

At least one item --- because at least a fraction of the item can be included.

At most n items --- because we can include the fraction of all the items

2) D) Θ(n log n) --- Time complexity is Θ(n log n)

3) F) fraction = remaining capacity / (value[i]/weight[i])

Because we need the remaining capacity to get the fraction

and value and weight of the item is important to calculate the fraction

value/weight gives a factor which can be used to calculate the fraction


Related Solutions

Knapsack algorithm problem: Consider the following variation of the Knapsack problem. There are n types of...
Knapsack algorithm problem: Consider the following variation of the Knapsack problem. There are n types of items, let call them 1,2,3,4,...,n. There are exactly c_i copies of item i, and each such copy has value v_i and weight w_i. As before, the knapsack capacity is W, and the other constraint is that you can only take at most c_i copies of item i ( since no more are available). Show how to compute the optimal value that can be achieved...
how to write a genetic algorithm for a knapsack problem .
how to write a genetic algorithm for a knapsack problem .
Implement the dynamic algorithm of 0-1 knapsack problem in Java. The following table shows 10 items,...
Implement the dynamic algorithm of 0-1 knapsack problem in Java. The following table shows 10 items, their values and weights. The maximum weight capacity of the knapsack is 113. What could be the maximum value of the knapsack and the most valuable set of items that fit in the knapsack? Item Weight Value 1 32 727 2 40 763 3 44 60 4 20 606 5 1 45 6 29 370 7 3 414 8 13 880 9 6 133...
Which of the following items best describes the role of CAD in an organization?
Which of the following items best describes the role of CAD in an organization?A) It generates artifacts that are of little or no significant valueB) Speed is a more important factor than quality when making geometryC) CAD enables communication and collaboration between groupsD) CAD hinders archival of intellectual property
Consider the following items in the Knapsack Problem: Item                weight             value &nbsp
Consider the following items in the Knapsack Problem: Item                weight             value            Knapsack capacity W = 9. 1                      3                   $6 2 4 $12 3                      2                  $10 4                      5                  $20 Determine the maximum value in the knapsack if we allow repetitions; i.e., if there are an unlimited number of each item so that more than one such item can be chosen. Find the missing value in the following linear array. P(w) is the maximum profit obtainable for a knapsack of capacity w. w-->             0       1      2       3       4       5       6       7       8       9 P(w):    0 0 10 10     20     20     30    30 40 ?   P(9)...
In C++ or Java Write the Greedy programming Algorithm for the 0-1 Knapsack problem.                    (a)...
In C++ or Java Write the Greedy programming Algorithm for the 0-1 Knapsack problem.                    (a) No fraction allowed Max Weight W= 9 item 1: profit $20, weight 2, prof/weight=$10 item 2: profit $30, weight 5, prof/weight=$6 item 3: profit $35, weight 7, prof/weight=$5 item 4: profit $12, weight 3, prof/weight=$4 item 5: profit $3, weight 1, prof/weight=$3
Which of the following best describes the problem of moral hazard in the labor market? a....
Which of the following best describes the problem of moral hazard in the labor market? a. Earning profits by hiring employees is exploitation and is unethical. b. Honesty isn’t always the best policy – morality can be hazardous. c. Once workers are hired, employers want to motivate those workers to work hard and be productive even though the workers would likely rather slack off. d. Potential employees have no incentive to reveal their true abilities or skill levels when applying...
Which of the following best describes the problem of moral hazard in the labor market? a....
Which of the following best describes the problem of moral hazard in the labor market? a. Once workers are hired, employers want to motivate those workers to work hard and be productive even though the workers would likely rather slack off. b. Honesty isn’t always the best policy – morality can be hazardous. c. Potential employees have no incentive to reveal their true abilities or skill levels when applying for a job opening, and employers would like to know this...
Consider the knapsack problem with the capacity C = 8 and 5 items with weights 6,...
Consider the knapsack problem with the capacity C = 8 and 5 items with weights 6, 4, 3, 7, 1. Find which items will exactly fill the knapsack using dynamic programming solution introduced in class. Show all your work. use I/O knapsack
Recall the dynamic programming algorithm we saw in class for solving the 0/1 knapsack problem for...
Recall the dynamic programming algorithm we saw in class for solving the 0/1 knapsack problem for n objects with a knapsack capacity of K. In particular, we characterized our recurrence OPT(j, W) to be following quantity: OPT(j, W) := The maximum profit that can be obtained when selecting from objects 1, 2, . . . , j with a knapsack capacity of W , where (after filling in our dynamic programming table), we return the value stored at OPT(n, K)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT