Quiz 4 - Dynamic Programming and Backtrackin Flashcards
Given two integer arrays to represent weights and profits of ’N’ items, find a subset of these items that will give us maximum profit such that their cumulative weight is not more than a given number ‘C’.
Best technique to solve this problem is?
- Divide and Conquer
- Dynamic Programming
- Brute Force
- Backtracking
- Dynamic Programming
To find the optimal solution for 0-1 knapsack, what would be dimensions of the extra array that we would need? The knapsack has a capacity of W, and there are total of n items. Assume we are using the approach that was discussed in the exploration.
Array[W+1][n+1]
We are given an array of numbers and we are asked to find an optimal solution to maximize the sum of numbers (i.e continuous subsequence that has maximum sum). if the order of the input numbers were altered or if we use a different algorithm, we will always end up with the same combination of numbers as answer.
False
Backtracking is used to solve which of the problems:
- Any numerical problems
- To find all possible solutions
- Optimal solution problems
- Problems that have sub-problems similar to divide and conquer
- To find all possible solutions
What is the correct recurrence formula for the unbound knapsack problem that was discussed in the exploration?
Consider the weight of the items w[1..n], value of the items v[1..n]
- F(x) = max{ F[x-vi] + wi }
- F(x) = max{ F[x-wi] + vi }
- F(x,i) = max{ vi + F[x-wi , i-1] , F[x , i -1] }
- F(x,v) = max{ F[x-wi] + vi }
- F(x) = max{ F[x-wi] + vi }
In the o-1 knapsack recurrence formula f(x,i) = max{ vi + f[x-wi , i-1] , f[x , i -1] }
The first part vi + f[x-wi , i-1] represents :
[ Select ]
The second part f[x , i -1] represents:
[ Select ]
adding the ith item to the knapsack
not adding the ith item to the knapsack